mirror of https://github.com/rwf2/Rocket.git
Fix decoding of String form values.
@liigo originated a fix and found the problem in #82.
This commit is contained in:
parent
83bbea7d4a
commit
0af01abe5f
|
@ -13,7 +13,7 @@ fn test_login(username: &str, password: &str, age: isize, status: Status,
|
||||||
let mut response = req.dispatch_with(&rocket);
|
let mut response = req.dispatch_with(&rocket);
|
||||||
let body_str = response.body().and_then(|body| body.into_string());
|
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);
|
assert_eq!(response.status(), status);
|
||||||
|
|
||||||
if let Some(string) = body {
|
if let Some(string) = body {
|
||||||
|
|
|
@ -74,8 +74,7 @@ impl<'v> FromFormValue<'v> for String {
|
||||||
// This actually parses the value according to the standard.
|
// This actually parses the value according to the standard.
|
||||||
fn from_form_value(v: &'v str) -> Result<Self, Self::Error> {
|
fn from_form_value(v: &'v str) -> Result<Self, Self::Error> {
|
||||||
let replaced = v.replace("+", " ");
|
let replaced = v.replace("+", " ");
|
||||||
let result = URI::percent_decode(replaced.as_bytes());
|
match URI::percent_decode(replaced.as_bytes()) {
|
||||||
match result {
|
|
||||||
Err(_) => Err(v),
|
Err(_) => Err(v),
|
||||||
Ok(string) => Ok(string.into_owned())
|
Ok(string) => Ok(string.into_owned())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue