Use urlencoding for db url params (fixes #2532) (#2537)

pull/2510/head
Nutomic 2 years ago committed by GitHub
parent a0a84d91ce
commit ceae0f5993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
Cargo.lock generated

@ -2225,6 +2225,7 @@ dependencies = [
"once_cell",
"openssl",
"parking_lot",
"percent-encoding",
"rand 0.8.5",
"regex",
"reqwest-middleware",

@ -2,4 +2,8 @@
# https://join-lemmy.org/docs/en/administration/configuration.html
{
hostname: lemmy-alpha
database: {
# Username to connect to postgres
user: "&££%^!£*!:::!"£:!:"
}
}

@ -44,6 +44,7 @@ html2text = "0.4.2"
rosetta-i18n = "0.1.2"
parking_lot = "0.12.1"
typed-builder = "0.10.0"
percent-encoding = "2.2.0"
[build-dependencies]
rosetta-build = "0.1.2"

@ -6,6 +6,7 @@ use crate::{
use anyhow::{anyhow, Context};
use deser_hjson::from_str;
use once_cell::sync::Lazy;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use regex::Regex;
use std::{env, fs, io::Error};
@ -44,7 +45,11 @@ impl Settings {
let conf = &self.database;
format!(
"postgres://{}:{}@{}:{}/{}",
conf.user, conf.password, conf.host, conf.port, conf.database,
utf8_percent_encode(&conf.user, NON_ALPHANUMERIC),
utf8_percent_encode(&conf.password, NON_ALPHANUMERIC),
conf.host,
conf.port,
utf8_percent_encode(&conf.database, NON_ALPHANUMERIC),
)
}

Loading…
Cancel
Save