fix(editor): handle --!> when stripping XML comment markers#66
Merged
Conversation
The toggle-comment command stripped --> but not --!>, the rare-but-legal HTML comment-end-bang form. Browsers (and the HTML spec) treat both as valid comment terminators; toggling-off a buffer that used the bang form would leave a stray --!> on the line. Side benefit: closes CodeQL alert #1 (js/bad-tag-filter) on this line. The alert was technically a false positive — the regex output is fed into Monaco's text buffer, never rendered as HTML — but the underlying incompleteness was real, so it's worth fixing rather than dismissing.
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.
What
One-line fix to the XML toggle-comment command so it strips both
-->and--!>from the end of commented lines.Why
CodeQL alert #1 (
js/bad-tag-filter, security-severity: high) flagged this regex as a bad-HTML-filtering pattern. After triage:editor.executeEdits(), neverinnerHTML'd or otherwise rendered as HTML. There's no XSS or sanitization-bypass risk; the user is editing their own document.--!>as well as-->(see Comment end bang state). Without the fix, toggling-off a comment that used the bang form would leave a dangling--!>on the line.Fixing the regex is one character (
!?) and a better story than dismissing the alert.Verification
npm run buildpasses locally (Vite 6.4.3, 121ms)