From 0af01abe5f9e8f69ffa85229f4834e268783e024 Mon Sep 17 00:00:00 2001 From: Liigo Zhuang Date: Fri, 30 Dec 2016 13:57:37 +0800 Subject: [PATCH] Fix decoding of String form values. @liigo originated a fix and found the problem in #82. --- examples/forms/src/tests.rs | 2 +- lib/src/request/form/from_form_value.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/forms/src/tests.rs b/examples/forms/src/tests.rs index 1e0ccb89..8e39f53c 100644 --- a/examples/forms/src/tests.rs +++ b/examples/forms/src/tests.rs @@ -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 { diff --git a/lib/src/request/form/from_form_value.rs b/lib/src/request/form/from_form_value.rs index 218badb4..012d2b94 100644 --- a/lib/src/request/form/from_form_value.rs +++ b/lib/src/request/form/from_form_value.rs @@ -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 { 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()) }