Skip to content
Snippets Groups Projects
Unverified Commit 3863ceb8 authored by Linfeng Qian's avatar Linfeng Qian
Browse files

Fix unicode url path panic bug (fix #43)

parent 53ea29a4
No related branches found
No related tags found
No related merge requests found
......@@ -377,7 +377,19 @@ impl Handler for MainHandler {
.path()
.into_iter()
.filter(|s| !s.is_empty())
.map(|s| PathBuf::from(&*percent_decode(s.as_bytes()).decode_utf8().unwrap()))
.map(|s| {
percent_decode(s.as_bytes())
.decode_utf8()
.map(|path| PathBuf::from(&*path))
.map_err(|_err| {
IronError::new(
StringError(format!("invalid path: {}", s)),
status::BadRequest,
)
})
})
.collect::<Result<Vec<PathBuf>, _>>()?
.into_iter()
.collect::<PathBuf>();
fs_path.push(&path_prefix);
let fs_path = fs_path.parse_dot().unwrap();
......
......@@ -40,8 +40,7 @@ impl RequestLogger {
(req.method.to_string().as_str(), &None),
(
percent_decode(req.url.as_ref().path().as_bytes())
.decode_utf8()
.unwrap()
.decode_utf8_lossy()
.to_string()
.as_str(),
&None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment