Skip to content

[NetworkReporter][iOS] Fix truncated non-ASCII text response bodies - #60322

Merged
huntie merged 1 commit into
mainfrom
pr60322
Dec 1, 2026
Merged

huntie merged 1 commit into
mainfrom
pr60322

Conversation

@huntie

@huntie huntie commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

RCTStringViewFromNSString sizes its std::string_view with -length, the UTF-16 code unit count, rather than the UTF-8 byte count of UTF8String. A text response body with non-ASCII characters is stored truncated, and when the cut lands mid-character, a debug app aborts on an assertion as DevTools requests the body.

  • Size the view with lengthOfBytesUsingEncoding:NSUTF8StringEncoding.

This affects RCTNetworking text responses and incremental bodies today, plus the text variant of maybeStoreResponseBody in #60188.

Changelog:
[iOS][Fixed] - React Native DevTools: Fix potential crash when truncating preview for text response bodies with non-ASCII characters

Test Plan

In RNTester on an iOS Simulator (debug), send an XHR to a URL returning {"text":"héllo 日本語 😀"} as text, then call Network.getResponseBody for it over CDP.

Before After
❌ Body cut inside 本; the app aborts in NSStringFromUTF8StringView while sending the CDP reply ✅ Full body returned

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 26, 2026
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 26, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 26, 2026
@huntie
huntie enabled auto-merge (squash) November 26, 2026 17:30
@huntie

huntie commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

@huntie-bot Pick to 0.89 when merged.

@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 5635ba20f281.

ios: no capture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants