Skip to content

[html] fix validation error on JavaScript block comment (for #171153) - #240932

Merged
Dmitriy Vasyura (dmitrivMS) merged 5 commits into
microsoft:mainfrom
Vector341:main
Jul 29, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 5 commits into
microsoft:mainfrom
Vector341:main

Conversation

@Vector341

Copy link
Copy Markdown
Contributor

Fix #171153

  1. convert html-like comments to normal comments before passing to JavaScript language server. Ref: https://262.ecma-international.org/6.0/#sec-html-like-comments.
  2. using regex with g flag to replace all occurrence of patterns instead of just replace the first one. (As I comments: [html] validation error on JavaScript block comment with arrow in HTML script #171153 (comment))

Actually, I wonder if it's right to do such thing in html-language-feature, since it's additional ECMAScript features for browsers. And here we can only do replacement based on raw text, so it's hard to implement some grammar in spec.

@Vector341

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Copilot AI review requested due to automatic review settings July 28, 2026 23:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes HTML validation errors caused by HTML-like markers in embedded JavaScript.

Changes:

  • Replaces single-line HTML comments using a global regex.
  • Adds embedded-content regression fixtures.
Show a summary per file
File Description
embeddedSupport.ts Updates HTML-comment conversion logic.
embedded.test.ts Adds block-comment and multiple-comment fixtures.

Review details

Comments suppressed due to low confidence (1)

extensions/html-language-features/server/src/modes/embeddedSupport.ts:202

  • This still corrupts valid JavaScript block comments when they contain a complete marker pair: /* <!-- --> */ becomes /* /* */ */, which produces the validation errors this fix is meant to avoid. Replacing each matched HTML-comment span with same-length whitespace (as suggested in the linked issue) avoids injecting nested delimiters and also preserves source positions; add this paired-marker regression case as well.
		return content.replace(SingleLineHTMLComment, (_, p1: string) => {
			return `/* ${p1} */`;
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

roblourens
roblourens previously approved these changes Jul 29, 2026
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) enabled auto-merge (squash) July 29, 2026 03:25
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 80fdba6 into microsoft:main Jul 29, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.132.0 milestone Jul 29, 2026
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.

[html] validation error on JavaScript block comment with arrow in HTML script

7 participants