From: Stefano Zacchiroli Date: Wed, 20 Nov 2002 13:58:22 +0000 (+0000) Subject: - bugfix: perform GET parameter parsing on HTTP encoded urls _then_ X-Git-Tag: V_0_0_5~28 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=12acd487ae0e4b47f044e22dfe703843c79fe102;p=helm.git - bugfix: perform GET parameter parsing on HTTP encoded urls _then_ decode them - removed now useless pair_of_2_sized_list --- diff --git a/helm/DEVEL/ocaml-http/http_parser.ml b/helm/DEVEL/ocaml-http/http_parser.ml index ea78eaf29..87b910010 100644 --- a/helm/DEVEL/ocaml-http/http_parser.ml +++ b/helm/DEVEL/ocaml-http/http_parser.ml @@ -53,14 +53,6 @@ let request_uri_syntax = { url_is_valid = (fun _ -> true); } - (** given a list of length 2 - @return a pair formed by the elements of the list - @raise Assert_failure if the list length isn't 2 - *) -let pair_of_2_sized_list = function - | [a;b] -> (a,b) - | _ -> assert false - (** given an HTTP like query string (e.g. "name1=value1&name2=value2&...") @return a list of pairs [("name1", "value1"); ("name2", "value2")] @raise Malformed_query if the string isn't a valid query string @@ -68,6 +60,7 @@ let pair_of_2_sized_list = function *) let split_query_params = let (bindings_sep, binding_sep) = (Pcre.regexp "&", Pcre.regexp "=") in + let http_decode url = Netencoding.Url.decode ~plus:false url in fun ~query -> let bindings = Pcre.split ~rex:bindings_sep query in if List.length bindings < 1 then @@ -77,7 +70,9 @@ let split_query_params = let pieces = Pcre.split ~rex:binding_sep binding in if List.length pieces <> 2 then raise (Malformed_query_binding (binding, query)); - pair_of_2_sized_list pieces) + (match pieces with + | [a; b] -> (http_decode a, http_decode b) + | _ -> assert false)) bindings (** given an input channel and a separator @@ -144,7 +139,9 @@ let parse_request = patch_empty_path (String.concat "/" (url_path request_uri)) in let query_params = - try split_query_params (url_query request_uri) with Not_found -> [] + try (* act on HTTP encoded URIs *) + split_query_params (url_query ~encoded:true request_uri) + with Not_found -> [] in Http_common.debug_print (sprintf