Fix decoding of String form values.

@liigo originated a fix and found the problem in #82.
This commit is contained in:
Liigo Zhuang 2016-12-30 13:57:37 +08:00 committed by Sergio Benitez
parent 83bbea7d4a
commit 0af01abe5f
2 changed files with 2 additions and 3 deletions

View File

@ -13,7 +13,7 @@ fn test_login(username: &str, password: &str, age: isize, status: Status,
let mut response = req.dispatch_with(&rocket);
let body_str = response.body().and_then(|body| body.into_string());
println!("Checking: {:?}/{:?}", username, password);
println!("Checking: {:?}/{:?}/{:?}/{:?}", username, password, age, body_str);
assert_eq!(response.status(), status);
if let Some(string) = body {

View File

@ -74,8 +74,7 @@ impl<'v> FromFormValue<'v> for String {
// This actually parses the value according to the standard.
fn from_form_value(v: &'v str) -> Result<Self, Self::Error> {
let replaced = v.replace("+", " ");
let result = URI::percent_decode(replaced.as_bytes());
match result {
match URI::percent_decode(replaced.as_bytes()) {
Err(_) => Err(v),
Ok(string) => Ok(string.into_owned())
}