Repository navigation
test: cover the CSS scanners' unterminated-string fallback arms - #1200
Merged
mrbobbytables merged 1 commit intoOct 8, 2026
Merged
Conversation
PR cncf#1176 added string-literal skipping to the image-set() argument walker and stripCssComments in scripts/lib/svg-active-content.mjs, each with a close === -1 fallback that scans to the end of the fragment. Neither arm had a test: coverage reported regions 414 and 463 uncovered. Pin both arms: an unterminated string inside image-set() does not hide the complete argument before it, and an unterminated CSS string copied verbatim keeps a /* opener literal so a later url() is still reported. scripts/lib/svg-active-content.mjs is now at its known floor: the only uncovered region left is the documented-unreachable ?? '' fallback. Closes cncf#1197 Refs cncf#1194 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
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.
Summary
PR #1176 added string-literal skipping to the
image-set()argument walker andstripCssCommentsinscripts/lib/svg-active-content.mjs, each carrying aclose === -1unterminated-string fallback that scans to the end of the fragment. Neither arm had unit coverage —npm run test:unit:coveragereported regions 414 and 463 uncovered (#1197).This adds the two tests #1197 asks for, pinning both arms:
image-set()does not hide the complete bare-string argument before it (covers the arm at line 414)/*opener inside it stays literal and a laterurl()is still reported (covers the arm at line 463)No source change.
scripts/lib/svg-active-content.mjsis now at its known floor: the only uncovered region left is the documented-unreachable?? ''fallback (region 251).Validation
node --test tests/svg-active-content.test.mjs: 121 pass, 0 failnpm run test:unit:coverage:check: passes;svg-active-content.mjs100% lines / 99.61% regions (only region 251 remains), source regions 2595/2596 (99.96%)Relationship to #1194
These two cases join the regression corpus that #1194 designates as the acceptance suite for the parser-based scanner — every past bypass/edge becomes a fixture the replacement gate must still satisfy. Landing them now closes #1197 without expanding the per-bypass patching loop (#1194 remains the structural fix).
Closes #1197
Refs #1194