Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape special chars in QueryParams #1597

Merged
merged 1 commit into from
Apr 20, 2023
Merged

Conversation

lagunoff
Copy link
Contributor

@lagunoff lagunoff commented Jul 19, 2022

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 — using urlEncodeBuilder True directly instead of toEncodedUrlPiece.

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 with toEncodedUrlPiece and that this should be changed in servant-client, even though it's weird that ToHttpAPIData only has method for encoding path pieces

@jkarni jkarni merged commit 79a29b0 into haskell-servant:master Apr 20, 2023
@jkarni
Copy link
Member

jkarni commented Apr 20, 2023

Thanks! And sorry this took so long.

@jkarni
Copy link
Member

jkarni commented Apr 20, 2023

@lagunoff @tomsmalley it ike this PR causes a failure (https://github.com/haskell-servant/servant/actions/runs/4752900295/jobs/8443824136#step:8:352) - not exactly sure why it didn't fail in the previous run though. Any thoughts on how to fix this?

@tomsmalley
Copy link

The failing test (binary data in query param) was introduced by the change which broke query param text encoding (#1432). I think it's either one or the other unless we add toEncodedQuery to ToHttpApiData. If the decision is to walk back #1432 then removing the test case seems fine.

@lagunoff
Copy link
Contributor Author

Hi, I'm afraid I can't provide any help with this issue. It's not clear what's going on under the hood in the test case it seems it sends a request and compares the response body, but I'm not familiar with the codebase can't dig deeper where exactly encoding/decoding fails

@ysangkok
Copy link
Contributor

For any subscribers on this issue, the failing test is proposed to be removed in #1679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query parameter encoding
4 participants