Repository: s-panferov/queryst (language: rust)

Issue:
Wrongly parsing space / +
Hello,

i have an input filed which should be send to the server for filtering which can be entered by an user. 
when he types `some words+` (a little contrieved, i know, but still possible) Google Chrome generates the following request to the server:
`https://server/api/endpoint?filter%5Bquery%5D=some+words%2B&page%5Bsize%5D=100` Which looks fine to me.
When parsing the querystring it gives the following result:
`Ok(Object({"filter": Object({"query": String("some+words+")}), "page": Object({"size": String("100")})}))`

In this Object the real plus is indistinguishable from the plus as space character.

This probably stems from first calling `url::percent_decode` and then using its own parse_pairs instead of directly using https://docs.rs/url/1.7.2/url/struct.Url.html#method.query_pairs 

I try an create a failing test in a PR and fix the problem later.

(There apparently is a difference between decoding a url and getting the query_params as pairs which has to do with if the parser is in urlformdecode mode or not. Don't Ask me)


Discussion / hints:

Fix patch:
diff --git a/src/parser.rs b/src/parser.rs
index 003d339..0469ab3 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -170,7 +170,7 @@ fn apply_object(keys: &[String], val: Value) -> Value {
 pub fn parse(params: &str) -> ParseResult<Value> {
     let tree = Object::new();
     let mut obj = Value::Object(tree);
-    let decoded_params = match decode_component(params) {
+    let decoded_params = match decode_component(&params.replace("+", " ")) {
         Ok(val) => val,
         Err(err) => return Err(ParseError{ kind: ParseErrorKind::DecodingError, message: err })
     };
@@ -261,4 +261,8 @@ mod tests {
         eq_str(parse("a%5B%5D=b&a%5B%5D=c&a%5B%5D=d").unwrap(),
             r#"{"a":["b","c","d"]}"#);
     }
+    #[test]
+    fn it_parses_plus_sign() {
+        eq_str(parse("a=b%20c+d%2B").unwrap(), r#"{"a":"b c d+"}"#);
+     }
 }


Test patch: