encode special characters in postgres url

This commit is contained in:
Ruben Fiszel
2023-08-25 14:38:30 +02:00
parent 8427f80f68
commit 23a662b94c
4 changed files with 8 additions and 4 deletions
+1
View File
@@ -7399,6 +7399,7 @@ dependencies = [
"tokio",
"tokio-postgres",
"tracing",
"urlencoding",
"uuid 1.4.1",
"windmill-api-client",
"windmill-audit",
+1 -1
View File
@@ -162,7 +162,7 @@ pub async fn cancel_job<'c: 'async_recursion>(
let add_job = add_completed_job_error(
&db,
&job_running,
format!("canceled by {username}: (force cancel: {force_cancel}"),
format!("canceled by {username}: (force cancel: {force_cancel})"),
serde_json::json!({"message": format!("Job canceled: {reason} by {username}"), "name": "Canceled", "reason": reason, "canceler": username}),
None,
rsmq.clone(),
+1
View File
@@ -69,6 +69,7 @@ rust_decimal.workspace = true
jsonwebtoken = { workspace = true, optional = true }
sha2 = { workspace = true, optional = true }
pem = { workspace = true, optional = true }
urlencoding.workspace = true
[build-dependencies]
deno_fetch.workspace = true
+5 -3
View File
@@ -19,6 +19,7 @@ use windmill_parser_sql::parse_pgsql_sig;
use crate::common::transform_json_value;
use crate::{AuthedClient, JobCompleted};
use urlencoding::encode;
#[derive(Deserialize)]
struct PgDatabase {
@@ -49,13 +50,14 @@ pub async fn do_postgresql(
let sslmode = database.sslmode.unwrap_or("prefer".to_string());
let database = format!(
"postgres://{user}:{password}@{host}:{port}/{dbname}?sslmode={sslmode}",
user = database.user.unwrap_or("postgres".to_string()),
password = database.password.unwrap_or("".to_string()),
host = database.host,
user = encode(&database.user.unwrap_or("postgres".to_string())),
password = encode(&database.password.unwrap_or("".to_string())),
host = encode(&database.host),
port = database.port.unwrap_or(5432),
dbname = database.dbname,
sslmode = sslmode
);
tracing::error!("database: {}", database);
let (client, handle) = if sslmode == "require" {
let (client, connection) = tokio_postgres::connect(
&database,