fix(static_file_handler): Support for blank spaces and percent encodi… - #457
fix(static_file_handler): Support for blank spaces and percent encodi…#457hdf1996 wants to merge 2 commits into
Conversation
|
This looks reasonable to me. We are now allocating a new String with each call, but I'm willing to pay that price. Could you add a unit test to verify percent decoding is working correctly? |
|
Thanks for the feedback @jolhoeft. I extracted the code to a fn to be able to test it easier, and included a few sample paths to the test |
| fn extract_path<'a, D>(&self, req: &'a mut Request<D>) -> Option<String> { | ||
| req.path_without_query().map(|path| { | ||
| debug!("{:?} {:?}{:?}", req.origin.method, self.root_path.display(), path); | ||
| let percent_decoded_path = percent_decode_path(path).unwrap(); |
There was a problem hiding this comment.
Sorry about losing track of this. I am a little concerned about the unwrap here. If that gets triggered, the current thread will be killed. That may be an opening for a DOS, where a series of ill formed URLs exhausts all the threads. We should probably change how we are handling threads to avoid that, but I want to defer that until after I get the async migration completed.
This should probably be changed to return None if the path cannot be decoded.
There was a problem hiding this comment.
Got it, will do. I might take some time to do the change since im busy with some personal stuff, but i'll make sure to do the change as soon as i have some free time. Thanks!
Summary
Adds handling for whitespaces in url for static files handler.
Issue
#405
Note
Im really new at Rust, and even more with ownership and low level memory handling, so probably i've made some mistakes in the way i changed this to a String. I'm more than open to hear suggestions on how to do this any better.
Fix inspired by lawliet89@f1c03e2