]> gitweb @ CieloNegro.org - Lucu.git/commitdiff
Bugfix: parseWWWFormURLEncoded now replaces each '+' to ' ', that were previously... RELEASE-0.7.0.3
authorPHO <pho@cielonegro.org>
Sun, 4 Sep 2011 12:13:05 +0000 (21:13 +0900)
committerPHO <pho@cielonegro.org>
Sun, 4 Sep 2011 12:13:05 +0000 (21:13 +0900)
Lucu.cabal
NEWS
Network/HTTP/Lucu/Utils.hs

index a5ea79344b15d6a2eb8514f12a3b95bb237cf06f..f9c03c76fdcc4e687b23ffb7f3e1f85c509bf1d2 100644 (file)
@@ -8,7 +8,7 @@ Description:
         without messing around FastCGI. It is also intended to be run
         behind a reverse-proxy so it doesn't have some facilities like
         logging, client filtering or such like.
-Version: 0.7.0.2
+Version: 0.7.0.3
 License: PublicDomain
 License-File: COPYING
 Author: PHO <pho at cielonegro dot org>
diff --git a/NEWS b/NEWS
index ef224809b90d3b19378b7c97b7337c4bba0ca1ee..0690289120e12d519fd2cbfea83e50315a65d07b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Changes from 0.7.0.2 to 0.7.0.3
+-------------------------------
+* Network.HTTP.Lucu.Utils: (reported by Ján Kľuka)
+
+  - Bugfix: parseWWWFormURLEncoded now replaces each '+' to ' ', that
+    were previously left unchaged.
+
+
 Changes from 0.7.0.1 to 0.7.0.2
 -------------------------------
 * Lucu now uses base64-bytestring instead of dataenc.
index c85c9a72b6a023241857ba1c613eb1e4d5a2485e..dbc65ac17ad8a52f553af26e5506a33df9aab137 100644 (file)
@@ -13,11 +13,11 @@ module Network.HTTP.Lucu.Utils
     , parseWWWFormURLEncoded
     )
     where
-
 import Control.Monad
 import Data.List     hiding (last)
 import Network.URI
 import Prelude       hiding (last)
+import Prelude.Unicode
 
 -- |> splitBy (== ':') "ab:c:def"
 --  > ==> ["ab", "c", "def"]
@@ -65,13 +65,20 @@ quoteStr !str = concat (["\""] ++ map quote str ++ ["\""])
 
 -- |> parseWWWFormURLEncoded "aaa=bbb&ccc=ddd"
 --  > ==> [("aaa", "bbb"), ("ccc", "ddd")]
-parseWWWFormURLEncoded :: String -> [(String, String)]
+parseWWWFormURLEncoded ∷ String → [(String, String)]
 parseWWWFormURLEncoded src
-    | src == "" = []
-    | otherwise = do pairStr <- splitBy (\ c -> c == ';' || c == '&') src
-                     let (key, value) = break (== '=') pairStr
-                     return ( unEscapeString key
-                            , unEscapeString $ case value of
-                                                 ('=':val) -> val
-                                                 val       -> val
+    | null src  = []
+    | otherwise = do pairStr ← splitBy (\ c → c ≡ ';' ∨ c ≡ '&') src
+                     let (key, value) = break ( '=') pairStr
+                     return ( unescape key
+                            , unescape $ case value of
+                                           ('=':val) → val
+                                           val       → val
                             )
+    where
+      unescape ∷ String → String
+      unescape = unEscapeString ∘ map plusToSpace
+
+      plusToSpace ∷ Char → Char
+      plusToSpace '+' = ' '
+      plusToSpace c   = c