Escape special chars in QueryParams #1597
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #1584
I was investigating a bug in our application and it turned out it was caused by servant-client not escaping plus signs in query params. After some digging down the code in servant-client I noticed servant-client uses
toEncodedUrlPiece
to encode the values of QueryParams, which is wrong because it should be used for path pieces only and it does not escape characters:@&=+$,
. Later I found #1584 and #1586. Here I'm suggesting a workaround — usingurlEncodeBuilder True
directly instead oftoEncodedUrlPiece
.At first I thought the
toEncodedUrlPiece
is itself the source of the problem and created a PR to fizruk/http-api-data#119. The conclusion there was that it is wrong to encode query params withtoEncodedUrlPiece
and that this should be changed in servant-client, even though it's weird that ToHttpAPIData only has method for encoding path pieces