From: PHO Date: Sun, 4 Sep 2011 12:19:53 +0000 (+0900) Subject: Merge branch 'master' into attoparsec X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=commitdiff_plain;h=e34910f85f459f049b9e6e6b79db9ef95dfccc13;hp=c6847797963abde98faf6aa6425c9bebc0e5dfb5 Merge branch 'master' into attoparsec Conflicts: Network/HTTP/Lucu/Utils.hs --- diff --git a/Lucu.cabal b/Lucu.cabal index e1650f8..0200e77 100644 --- a/Lucu.cabal +++ b/Lucu.cabal @@ -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 diff --git a/NEWS b/NEWS index ef22480..0690289 100644 --- 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. diff --git a/Network/HTTP/Lucu/Utils.hs b/Network/HTTP/Lucu/Utils.hs index abd4556..d254169 100644 --- a/Network/HTTP/Lucu/Utils.hs +++ b/Network/HTTP/Lucu/Utils.hs @@ -67,11 +67,18 @@ quoteStr str = A.toAsciiBuilder "\"" ⊕ -- > ==> [("aaa", "bbb"), ("ccc", "ddd")] 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