fix: escape filename (#21)

close #19
This commit is contained in:
sigoden
2022-06-06 06:51:35 +08:00
committed by GitHub
parent a0b413ef30
commit f138915f20
5 changed files with 27 additions and 7 deletions

View File

@@ -143,7 +143,7 @@ impl Args {
let uri_prefix = if path_prefix.is_empty() {
"/".to_owned()
} else {
format!("/{}/", &path_prefix)
format!("/{}/", encode_uri(&path_prefix))
};
let cors = matches.is_present("cors");
let auth = match matches.value_of("auth") {
@@ -237,3 +237,8 @@ pub fn load_private_key(filename: &str) -> BoxResult<PrivateKey> {
}
Ok(PrivateKey(keys[0].to_owned()))
}
pub fn encode_uri(v: &str) -> String {
let parts: Vec<_> = v.split('/').map(urlencoding::encode).collect();
parts.join("/")
}