fix: b64 encode props with URL-sensitive characters#530
Merged
Conversation
Props containing characters like #, ?, /, \, =, & produce percent-encoded sequences (%23, %3F, etc.) that get decoded by proxies, CDNs, and prerender crawlers, breaking URL parsing. Now these values use the existing ~<b64> encoding path instead, eliminating percent-encoded characters from URLs. Fixes #529, fixes #528
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
Fixes #529, fixes #528
❓ Type of change
📚 Description
Props containing URL-sensitive characters (
#,?,/,\,=,&,,, etc.) were percent-encoded byencodeURIComponent, producing%23,%3F, etc. in the URL path. Intermediaries (proxies, CDNs, h3, prerender crawlers) decode these unpredictably, breaking URL parsing.?becomes a query delimiter,#becomes a fragment,/splits the path segment.The fix: after
encodeURIComponent, if the result contains%, use the existing~<b64>encoding path instead. This eliminates percent-encoded characters from URLs entirely while keeping simple ASCII values human-readable.Impact on #529: Characters like
#,?,\indefineOgImageprops no longer break image generation.Impact on #528: Full image URLs as props (e.g.
https://images.prismic.io/xxx/img.png?auto=format,compress) are now preserved intact through encoding/decoding.Backward compatible: the decoder already handles both
%-encoded (legacy) and~-prefixed (b64) values.Adds 38 new tests including stress tests for path injection, extension confusion, param injection, null bytes, every ASCII special character, and verifies encoded output never contains raw
#,?,/,\,=,&, or%.