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

UTF-8 body corruption #118

Closed
jamiehodge opened this issue Jan 9, 2024 · 2 comments
Closed

UTF-8 body corruption #118

jamiehodge opened this issue Jan 9, 2024 · 2 comments
Labels
bug Something isn't working released Has been released and published

Comments

@jamiehodge
Copy link

Expected Behaviour
One expects the default/fallback behaviour to correctly assemble UTF-8 multibyte characters in the request body.

Actual Behaviour
The default/fallback behaviour incorrectly assembles requests that exceed the input stream chunk size. Multibyte characters that straddle chunks are incorrectly parsed, resulting in replacement characters or arbitrary single byte characters.

Example: https://github.com/graphql/graphql-http/blob/main/src/use/http.ts#L144-L146

Debug Information
Send an HTTP request with a variable assigned to a large number of fx "å" that exceeds the request body stream high-water mark. The value passed to the schema will be intermittently corrupted.

Further Information
It appears as though simply calling req.setEncoding("utf8"); is enough to address the issue.

@enisdenjo
Copy link
Member

Hey there, thanks for opening this issue and for the great find! A PR would be very welcome and appreciated if willing; no worries though, otherwise I'll handle it. 👍

@enisdenjo enisdenjo added the bug Something isn't working label Jan 26, 2024
enisdenjo pushed a commit that referenced this issue Apr 10, 2024
## [1.22.1](v1.22.0...v1.22.1) (2024-04-10)

### Bug Fixes

* **audit/render:** Omit `set-cookie` header and html body ([#116](#116)) ([1c5c744](1c5c744))
* **handler:** Support both utf-8 and utf8 charsets ([94100d6](94100d6)), closes [#120](#120)
* **use:** Set request readable encoding to utf-8 ([50d3bcd](50d3bcd)), closes [#118](#118)
@enisdenjo
Copy link
Member

🎉 This issue has been resolved in version 1.22.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@enisdenjo enisdenjo added the released Has been released and published label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released Has been released and published
Projects
None yet
Development

No branches or pull requests

2 participants