From: Stephane Glondu <steph@glondu.net>
Date: Thu, 7 Jul 2011 16:47:00 +0200
Subject: Fix wrong decoding of + in URL paths

Cherry-picked from upstream.
---
 baselib/ocsigen_lib.ml |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/baselib/ocsigen_lib.ml b/baselib/ocsigen_lib.ml
index 376fe3a..15af400 100644
--- a/baselib/ocsigen_lib.ml
+++ b/baselib/ocsigen_lib.ml
@@ -509,7 +509,8 @@ let string_of_url_path ~encode l =
   then
     fixup_url_string (String.concat "/"
                         (List.map (*Netencoding.Url.encode*) 
-                           MyUrl.encode l))
+                           (MyUrl.encode ~plus:false) l))
+        (* ' ' are not encoded to '+' in paths *)
   else String.concat "/" l (* BYXXX : check illicit characters *)
 
 let parse_url =
@@ -561,6 +562,12 @@ let parse_url =
 
     (* Note that the fragment (string after #) is not sent by browsers *)
 
+(*20110707 ' ' is encoded to '+' in queries, but not in paths. 
+  Warning: if we write the URL manually, we must encode ' ' to '+' manually
+  (not done by the browser).
+  --Vincent
+*)
+
     let get_params =
       lazy begin
         let params_string = match query with None -> "" | Some s -> s in
@@ -570,7 +577,7 @@ let parse_url =
       end
     in
 
-    let path = List.map Netencoding.Url.decode (Neturl.split_path pathstring) in
+    let path = List.map (Netencoding.Url.decode ~plus:false) (Neturl.split_path pathstring) in
 
     let path = remove_dotdot path (* and remove "//" *)
         (* here we remove .. from paths, as it is dangerous.
-- 
