From 3177a876bea6b8a2c34f51cc96c98c2cbb1e4aa9 Mon Sep 17 00:00:00 2001 From: PHO Date: Sun, 4 Sep 2011 21:13:05 +0900 Subject: [PATCH] Bugfix: parseWWWFormURLEncoded now replaces each '+' to ' ', that were previously left unchaged. --- Lucu.cabal | 2 +- NEWS | 8 ++++++++ Network/HTTP/Lucu/Utils.hs | 25 ++++++++++++++++--------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Lucu.cabal b/Lucu.cabal index a5ea793..f9c03c7 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 c85c9a7..dbc65ac 100644 --- a/Network/HTTP/Lucu/Utils.hs +++ b/Network/HTTP/Lucu/Utils.hs @@ -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 -- 2.40.0