margelo / margelo/react-native-nitro-fetch

Preserve original response bytes when Content-Type specifies a non-UTF-8 charset

Open
#190 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.