Repository navigation
Escape attribute values in attribution markup builder - #5607
Merged
Merged
Conversation
The `h()` helper interpolated attribute values directly into the tag string while only text-node content was escaped. Apply the existing `escapeHtml` to attribute values too, and validate the URL scheme in `extLink` so only http(s)/mailto hrefs are emitted. Adds unit coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The obfuscated-javascript: test asserted on the raw attribute text, where the embedded tab means 'javascript' never appears — the assertion passed even with sanitizeHref removed. Assert on the parsed href property, which normalizes away the control characters, and run Prettier on the spec. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Latest k6 run output1Footnotes
|
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.
Description
The attribution HTML builder's
h()helper interpolated attribute values straight into the tag string, while only text-node content was passed throughescapeHtml. This tightens the builder so attribute values get the same treatment:escapeHtmlto attribute values inh(), consistent with how text nodes are already handled.extLink()— onlyhttp(s)/mailtohrefs are emitted; anything else falls back toabout:blank. Leading/embedded control characters and spaces are stripped before the scheme check to match how browsers parse URLs.Keeps the rendered output identical for the normal case (URLs,
src,style,classare unaffected) while making the generated markup robust against unexpected characters in provider-supplied metadata fields.Testing Instructions
cd frontend && pnpm test:unit test/unit/specs/utils/attribution-html.spec.tsChecklist
🤖 Generated with Claude Code