Skip to content

Commit

Permalink
Fix decoding of String form values.
Browse files Browse the repository at this point in the history
@liigo originated a fix and found the problem in #82.
  • Loading branch information
liigo authored and SergioBenitez committed Dec 31, 2016
1 parent 83bbea7 commit 0af01ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/forms/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/request/form/from_form_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit 0af01ab

Please sign in to comment.