margelo / margelo/react-native-nitro-fetch
Preserve original response bytes when Content-Type specifies a non-UTF-8 charset
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 997
- Forks
- 50
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 14
Description
Both native clients currently decode Content-Type charset and omit bodyBytes whenever decoding succeeds. JavaScript arrayBuffer()/bytes() then reconstruct UTF-8 bytes from bodyString. For example a one-byte ISO-8859-1 e9 payload becomes c3 a9, corrupting the original body. The same issue affects the duplicated iOS prefetch path.\n\nProposed correction: use lossless strict UTF-8 only for the text bridge optimization and otherwise bridge original bytes; Fetch text()/json() use UTF-8 irrespective of Content-Type charset. This also removes repeated Android charset regex/decoder allocation and the iOS charset parser. I will document the observable correction for applications relying on legacy charset decoding and verify byte-for-byte behavior for UTF-8, invalid UTF-8, Latin-1 and UTF-16 payloads.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace the response bridges in both native clients and the duplicated iOS prefetch path, starting with how Content-Type charset decoding determines whether bodyBytes is exposed. Compare the text bridge optimization with the original-byte path, then verify byte-for-byte behavior for UTF-8, invalid UTF-8, Latin-1, and UTF-16 payloads while confirming Fetch text() and json() use UTF-8.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, react-native
- Domain
- mobile-dev, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100