Skip to content

fix(remark-snackplayer): avoid double-decoding metadata - #5324

Merged
Simek merged 2 commits into
react:mainfrom
ZainnQureshii:fix/snackplayer-double-decode
Nov 11, 2026
Merged

Simek merged 2 commits into
react:mainfrom
ZainnQureshii:fix/snackplayer-double-decode

Conversation

@ZainnQureshii

Copy link
Copy Markdown
Contributor

Summary

URLSearchParams already decodes metadata in plugins/remark-snackplayer/src/index.ts:15, so the second decode made name=100%25%20ready throw URIError: URI malformed.

Use the parsed values directly at plugins/remark-snackplayer/src/index.ts:36, :37 and :38, keeping the existing Example, Example usage and tsx fallbacks. The name above now produces data-snack-name="100% ready" without rejecting Markdown processing.

For input literal%20%2520%20text, the plugin's generated name and description attributes now contain literal %20 text instead of literal text. The serialized filename is likewise App.literal %20 text instead of App.literal text. These claims cover generated metadata, and do not establish Expo iframe behavior or successful bundling of percent-bearing filenames.

Test plan

Run from the repository root, using isolated dependencies with direct runtime, TypeScript, formatter and lint-tool versions matched to yarn.lock:

  • yarn --cwd plugins/remark-snackplayer test: with production fix reverted and regression tests kept, exit 1, 2 passed and 6 failed. With only the extension decode restored, exit 1, 6 passed and 2 failed. With the full fix, exit 0, 8 passed and 0 failed.
  • yarn --cwd plugins/remark-snackplayer test: with only the original fixture tests, exit 0, 2 passed and 0 failed. Regression tests were restored afterward.
  • yarn prettier --check plugins/remark-snackplayer/src/index.ts plugins/remark-snackplayer/tests/index.ts: exit 0, both files pass.
  • yarn eslint plugins/remark-snackplayer/src/index.ts plugins/remark-snackplayer/tests/index.ts: exit 0, no lint diagnostics.
  • yarn --cwd plugins/remark-snackplayer lint: exit 2 before and after the production fix, with the same TS2769 visitor type incompatibility at visit() (old line 90, new line 88). The chained ESLint step is not reached.
  • git diff --check: exit 0.

Full website build and live Expo behavior were not tested.

Changelog:

[Internal] [Fixed] - Avoid decoding SnackPlayer metadata twice during Markdown processing.

Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.

🤖 Generated with Claude Code

parseParams already decodes each SnackPlayer meta value, and the plugin decoded name, description and ext a second time, so an encoded % sequence in a value (such as %2520) was turned into a different character. Use the parsed values as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla meta-cla Bot added the CLA Signed label Nov 10, 2026
@Simek

Simek commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Hey @ZainnQureshii, can you link the page on which you see mentioned URIError: URI malformed error?

@ZainnQureshii

Copy link
Copy Markdown
Contributor Author

Hey, no page hits it right now, all 2,274 SnackPlayer blocks in the docs only use %20 and %2C in their metadata, and those come out the same whether they're decoded once or twice. It shows up as soon as a name or description has a literal percent sign, so name=100%25%20width comes out of URLSearchParams as 100% width and the second decodeURIComponent then throws URIError: URI malformed, which stops the Markdown processing for that page. So it's a latent bug rather than something broken on the site today.

@Simek Simek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that edge case, and the fix! 👍

@Simek
Simek merged commit 753bf68 into react:main Nov 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants