test(svg-active-content): cover single-quoted and unquoted attribute values - #680
Closed
hivecommons-hive[bot] wants to merge 1 commit into
Closed
hivecommons-hive[bot] wants to merge 1 commit into
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
…values ATTRIBUTE_PATTERN in scripts/lib/svg-active-content.mjs accepts three attribute value forms -- double-quoted, single-quoted and unquoted -- and findActiveContent and stripActiveContent read them through the fallback chains 'match[2] ?? match[3] ?? match[4]' and 'dq ?? sq ?? uq'. Every existing case wrote double-quoted markup, so only the first alternative of either chain ran: a regression that dropped an alternative from the pattern, or read the wrong capture group, would leave the suite green while onclick='alert(1)' and href=javascript:alert(1) passed the sanitizer unseen. Add quoting variants for the three attribute classes the scanner recognises -- event handler, script URI, embedded document -- plus an inert-value case proving the pattern does not over-match. Region coverage for scripts/lib/svg-active-content.mjs rises 93.18% -> 97.73% and src files 97.95% -> 98.20%. The two remaining '?? ""' tails are unreachable, since the regex cannot match with all three capture groups undefined. Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
This was referenced Sep 26, 2026
Closed
Member
|
Superseded by #750, which consolidates this and 14 other test-only coverage PRs into a single reviewable change (commit cherry-picked unmodified, authorship and DCO preserved). |
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.
Test Improvement
Adds quoting-variant cases to
tests/svg-active-content.test.mjsforfindActiveContentandstripActiveContentinscripts/lib/svg-active-content.mjs. No production code changes.ATTRIBUTE_PATTERNaccepts three value forms that browsers treat identically — double-quoted, single-quoted and unquoted — and both consumers read the value through a fallback chain:match[2] ?? match[3] ?? match[4](line 175) anddq ?? sq ?? uq(line 270). All 23 existing cases wrote double-quoted markup, so only the first alternative of either chain ever ran. A regression that dropped an alternative from the pattern, or read the wrong capture group, would have left the suite green whileonclick='alert(1)',href=javascript:alert(1)andsrcdoc=payloadpassed the sanitizer unseen.The sanitizer is correct today — these are regression locks on a security boundary, not a bug fix.
Eight new cases, generated over the single-quoted/unquoted pair:
onclick)href=javascript:)srcdoc)fill,width)Coverage
Raw V8 coverage merged with
tests/tools/coverage-report.mjssemantics, measured before and after on this branch:scripts/lib/svg-active-content.mjsregionssrc filesregionsFour of the six uncovered sub-line regions close. The two remaining
?? ''tails are unreachable: the regex cannot match with all three capture groups undefined, so they are defensive only and no test can reach them.npm run test:unit:coverage:checkpasses (fail 0);npx prettier --check tests/svg-active-content.test.mjsis clean.Disjoint from the open queue
Touches one file,
tests/svg-active-content.test.mjs. #676 touchesscripts/lib/mdx-active-content.mjsandtests/mdx-active-content.test.mjs; #678 touchestests/helpers-import-sandbox.mjsandtests/import-architectures-fallbacks.test.mjs; #674 touchespackage.json. No overlap in files, functions or tracker cluster.Related Issue
Closes #679
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88