Skip to content

Commit b3279d9

Browse files
committed
Escape special chars in QueryParams
1 parent f0e2316 commit b3279d9

File tree

1 file changed

+4
-3
lines changed
  • servant-client-core/src/Servant/Client/Core

1 file changed

+4
-3
lines changed

servant-client-core/src/Servant/Client/Core/Request.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ import Network.HTTP.Media
5151
(MediaType)
5252
import Network.HTTP.Types
5353
(Header, HeaderName, HttpVersion (..), Method, QueryItem,
54-
http11, methodGet)
54+
http11, methodGet, urlEncodeBuilder)
5555
import Servant.API
56-
(ToHttpApiData, toEncodedUrlPiece, toHeader, SourceIO)
56+
(ToHttpApiData, toEncodedUrlPiece, toQueryParam, toHeader, SourceIO)
5757

5858
import Servant.Client.Core.Internal (mediaTypeRnf)
5959

@@ -165,7 +165,8 @@ appendToQueryString pname pvalue req
165165
-- | Encode a query parameter value.
166166
--
167167
encodeQueryParamValue :: ToHttpApiData a => a -> BS.ByteString
168-
encodeQueryParamValue = LBS.toStrict . Builder.toLazyByteString . toEncodedUrlPiece
168+
encodeQueryParamValue = LBS.toStrict . Builder.toLazyByteString
169+
. urlEncodeBuilder True . encodeUtf8 . toQueryParam
169170

170171
-- | Add header to the request being constructed.
171172
--

0 commit comments

Comments
 (0)