Skip to content

fix(parse): end raw-text tags on a solidus - #21

Closed
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-8ae8
Closed

cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-8ae8

Conversation

@cursor

@cursor cursor Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Bug

</script/ is a real script end tag in HTML (the end-tag name may be followed by >, whitespace, or /). htmlparser2 only accepts > and whitespace, and ForeignTokenizer inherits that check.

A page such as:

<script src="/app.js"></script/>
<script src="/widgets.js"></script>

loads both scripts in a browser. html-scripts returned only /app.js. The same hole drops a script that follows </style/, </title/, </textarea/, or </xmp/, and it drops a script written after a breakout inside an inline script (var x = "</script/><script src='/evil.js'>">).

Fix

When the raw-text end sequence has matched and the next character is /, treat it like whitespace so the closing-tag state finishes the tag at the next >. </scripting> is unchanged: the extra letter means it is not an end tag.

Validation

standard on the changed files, and ava test/index.js (35 tests, including the new solidus cases and the existing script/svg/math suite).

Open in Web View Automation 

htmlparser2 only ends script, style, title, textarea, and xmp on ">" or
whitespace. A "</script/" end tag therefore stays open and swallows every
later tag, so scripts the browser runs are dropped from the result.

Co-authored-by: kikohumanbeatbox <kikohumanbeatbox@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 65640714-a89b-4371-8007-1da97433a6ab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

html-scripts

Details
Benchmark suite Current: 76ed901 Previous: 13370d5 Ratio
getScripts 1MB page 64.3 ms (64.2-68.8) 92 ms (90.6-99.3) 0.70
getScripts 20KB page 87.1 ms (86.6-88.6) 115.6 ms (114.8-117.7) 0.75

This comment was automatically generated by workflow using github-action-benchmark.

Kikobeats added a commit that referenced this pull request Oct 28, 2026
Carried over from #21. htmlparser2 v12 already handles it; this locks it in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kikobeats

Copy link
Copy Markdown
Owner

Superseded by #22. htmlparser2 v12 ends raw-text end tags on a solidus natively (</script/, </style/, </title/, </textarea/, </xmp/), and #22 removed the ForeignTokenizer subclass this patched. Every case here matches parse5 on master. The tests from this PR are on master in 336a5a1 (released in 2.0.1) so the behaviour stays locked in.

@Kikobeats Kikobeats closed this Oct 28, 2026
@Kikobeats
Kikobeats deleted the cursor/critical-bug-management-8ae8 branch October 28, 2026 09:07
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.

2 participants