Fix: URL encode transform parameters to handle special characters#4
Open
richardfrankza wants to merge 1 commit intolenvanessen:masterfrom
Open
Fix: URL encode transform parameters to handle special characters#4richardfrankza wants to merge 1 commit intolenvanessen:masterfrom
richardfrankza wants to merge 1 commit intolenvanessen:masterfrom
Conversation
Special characters in transform parameters (like # in background colors) need to be URL-encoded to avoid HTML attribute parsing issues. For example, background=#FFFFFF now becomes background=%23FFFFFF This ensures the srcset attribute is properly formatted when rendered in HTML.
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.
Problem
Special characters in transform parameters (like
#in background colors) are not being URL-encoded, which causes HTML attribute parsing issues.For example,
background=#FFFFFFin the generated URL breaks thesrcsetattribute because the#character is not properly escaped.Solution
Added
rawurlencode()when building the transform directive URL parameters. This ensures special characters are properly encoded:#FFFFFFbecomes%23FFFFFF,,=, etc. are also properly handledExample
Before:
After:
Testing
Tested with letterbox mode using a white background (
#FFFFFF) and confirmed the URLs are now properly encoded in the rendered HTML attributes.