Skip to content

fix: serialize URLs used in native download JavaScript - #79

Merged
joaoloureirop merged 3 commits into
mainfrom
fix/serialize-injected-download-urls
Sep 16, 2026
Merged

joaoloureirop merged 3 commits into
mainfrom
fix/serialize-injected-download-urls

Conversation

@joaoloureirop

@joaoloureirop joaoloureirop commented Sep 7, 2026 •

Copy link
Copy Markdown

Summary

  • Encode URL values with JSON string serialization (RCTJSONStringify on iOS, JSONObject.quote on Android) before inserting them into native-generated JavaScript for file downloads and iframe URL reporting.
  • If serialization fails, skip evaluating the generated script instead of using the raw URL string.

Mobile can consume this via a published package bump.

Test plan

  • iOS: downloading a PDF from the in-app browser still shows the download prompt and completes
  • iOS: a download URL whose path contains an apostrophe still downloads
  • Android: blob downloads still work for typical blob URLs and URLs with special characters

Unescaped urlString interpolation in download and iframe scripts allowed
crafted URLs to break out of JS string literals and run in the current
page origin. Serialize with RCTJSONStringify / JSONObject.quote instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
@joaoloureirop joaoloureirop changed the title fix: JSON-serialize URLs before evaluateJavaScript injection fix: serialize URLs used in native download JavaScript Sep 14, 2026
@joaoloureirop
joaoloureirop enabled auto-merge (squash) September 16, 2026 13:40
@joaoloureirop
joaoloureirop merged commit 4ed0b4c into main Sep 16, 2026
8 checks passed
@joaoloureirop
joaoloureirop deleted the fix/serialize-injected-download-urls branch September 16, 2026 13:40
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.

2 participants