Skip to content

test: cover the CSS scanners' unterminated-string fallback arms - #1200

Merged
mrbobbytables merged 1 commit into
cncf:mainfrom
mrbobbytables:scanner-unterminated-string-tests
Oct 8, 2026
Merged

mrbobbytables merged 1 commit into
cncf:mainfrom
mrbobbytables:scanner-unterminated-string-tests

Conversation

@mrbobbytables

Copy link
Copy Markdown
Member

Summary

PR #1176 added string-literal skipping to the image-set() argument walker and stripCssComments in scripts/lib/svg-active-content.mjs, each carrying a close === -1 unterminated-string fallback that scans to the end of the fragment. Neither arm had unit coverage — npm run test:unit:coverage reported regions 414 and 463 uncovered (#1197).

This adds the two tests #1197 asks for, pinning both arms:

  • an unterminated string inside image-set() does not hide the complete bare-string argument before it (covers the arm at line 414)
  • an unterminated CSS string is copied verbatim to the end of the fragment, so a /* opener inside it stays literal and a later url() is still reported (covers the arm at line 463)

No source change. scripts/lib/svg-active-content.mjs is 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 fail
  • npm run test:unit:coverage:check: passes; svg-active-content.mjs 100% 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

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>
@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 8, 2026
Merged via the queue into cncf:main with commit 6ba0892 Oct 8, 2026
7 checks passed
@mrbobbytables
mrbobbytables deleted the scanner-unterminated-string-tests branch October 16, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] svg-active-content.mjs: unterminated-string arms in #1176's two new CSS scanners have no unit coverage

1 participant