fix: handle URIError when HTML attributes contain % character #754
+53
−2
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.
Parsing HTML with attributes containing
%(e.g.,width="100%") throwsURIError: URI malformedin v9. ThedecodeURIComponent()call inparseHTMLAttributeswasn't wrapped in try-catch.Changes
decodeURIComponent(attrs)in try-catch to handle invalid URI encodings gracefully%present (perf optimization)%in attribute valuesExample
Security sanitization for malicious content (
javascript:URLs, etc.) remains intact.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Note
Safely handles '%' in HTML attribute strings during sanitization to avoid URIError, with regression tests added and a patch changeset.
parseHTMLAttributesinsrc/parse.tsto guarddecodeURIComponentwith conditional%check and try/catch; fallback to raw regex when no%, preserving sanitization and preventing exceptions.src/parse.spec.tsfor parsing HTML with%in attributes viaparserandparseHTMLTag(e.g.,<iframe ... width="100%">)..changeset/fix-urierror-html-attributes.md(patch) documenting the bugfix.Written by Cursor Bugbot for commit 0edf88e. This will update automatically on new commits. Configure here.