From b3279d9e1974853654d328fbd64e8e3237a1af39 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Wed, 20 Jul 2022 00:34:49 +0400 Subject: [PATCH] Escape special chars in QueryParams --- servant-client-core/src/Servant/Client/Core/Request.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/servant-client-core/src/Servant/Client/Core/Request.hs b/servant-client-core/src/Servant/Client/Core/Request.hs index 431b1f07..d00cd995 100644 --- a/servant-client-core/src/Servant/Client/Core/Request.hs +++ b/servant-client-core/src/Servant/Client/Core/Request.hs @@ -51,9 +51,9 @@ import Network.HTTP.Media (MediaType) import Network.HTTP.Types (Header, HeaderName, HttpVersion (..), Method, QueryItem, - http11, methodGet) + http11, methodGet, urlEncodeBuilder) import Servant.API - (ToHttpApiData, toEncodedUrlPiece, toHeader, SourceIO) + (ToHttpApiData, toEncodedUrlPiece, toQueryParam, toHeader, SourceIO) import Servant.Client.Core.Internal (mediaTypeRnf) @@ -165,7 +165,8 @@ appendToQueryString pname pvalue req -- | Encode a query parameter value. -- encodeQueryParamValue :: ToHttpApiData a => a -> BS.ByteString -encodeQueryParamValue = LBS.toStrict . Builder.toLazyByteString . toEncodedUrlPiece +encodeQueryParamValue = LBS.toStrict . Builder.toLazyByteString + . urlEncodeBuilder True . encodeUtf8 . toQueryParam -- | Add header to the request being constructed. --