url encoding changes
This commit is contained in:
parent
df4c292ddb
commit
0ec21d198a
3 changed files with 11 additions and 12 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -801,7 +801,7 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"log",
|
"log",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"url",
|
"urlencoding",
|
||||||
"v_htmlescape",
|
"v_htmlescape",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1587,6 +1587,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urlencoding"
|
||||||
|
version = "2.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf16_iter"
|
name = "utf16_iter"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
|
|
@ -18,7 +18,7 @@ futures = "0.3.24"
|
||||||
percent-encoding = "2.2"
|
percent-encoding = "2.2"
|
||||||
v_htmlescape = "0.15"
|
v_htmlescape = "0.15"
|
||||||
bytesize = "1.3.0"
|
bytesize = "1.3.0"
|
||||||
url = "2.5.4"
|
urlencoding = "2.1.3"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 'z'
|
opt-level = 'z'
|
||||||
|
|
|
@ -4,7 +4,6 @@ use actix_web::{HttpRequest, HttpResponse};
|
||||||
use bytesize::ByteSize;
|
use bytesize::ByteSize;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use url::form_urlencoded;
|
|
||||||
use v_htmlescape::escape as escape_html_entity;
|
use v_htmlescape::escape as escape_html_entity;
|
||||||
|
|
||||||
// " -- " & -- & ' -- ' < -- < > -- > / -- /
|
// " -- " & -- & ' -- ' < -- < > -- > / -- /
|
||||||
|
@ -18,7 +17,7 @@ pub fn directory_listing(
|
||||||
dir: &Directory,
|
dir: &Directory,
|
||||||
req: &HttpRequest,
|
req: &HttpRequest,
|
||||||
) -> Result<ServiceResponse, std::io::Error> {
|
) -> Result<ServiceResponse, std::io::Error> {
|
||||||
let index_of = req.path().trim_end_matches('/');
|
let index_of = urlencoding::decode(req.path().trim_end_matches('/')).unwrap();
|
||||||
let mut body = String::new();
|
let mut body = String::new();
|
||||||
let base = Path::new(req.path());
|
let base = Path::new(req.path());
|
||||||
|
|
||||||
|
@ -38,17 +37,11 @@ pub fn directory_listing(
|
||||||
for entry in paths {
|
for entry in paths {
|
||||||
let p: String = match entry.path().strip_prefix(&dir.path) {
|
let p: String = match entry.path().strip_prefix(&dir.path) {
|
||||||
Ok(p) if cfg!(windows) => base
|
Ok(p) if cfg!(windows) => base
|
||||||
.join(
|
.join(&*urlencoding::encode(p.to_str().unwrap()))
|
||||||
form_urlencoded::byte_serialize(p.as_os_str().as_encoded_bytes())
|
|
||||||
.collect::<String>(),
|
|
||||||
)
|
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.replace('\\', "/"),
|
.replace('\\', "/"),
|
||||||
Ok(p) => base
|
Ok(p) => base
|
||||||
.join(
|
.join(&*urlencoding::encode(&p.to_str().unwrap()))
|
||||||
form_urlencoded::byte_serialize(p.as_os_str().as_encoded_bytes())
|
|
||||||
.collect::<String>(),
|
|
||||||
)
|
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.into_owned(),
|
.into_owned(),
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
|
|
Loading…
Add table
Reference in a new issue