Report from: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8359 (also apply to latest SciTE).
Closing "-->" HTML comment in JS string inside HTML file is trate as comment (but should be string).
Code to reproduce:
<!DOCTYPE html>
<script>
var example = "<!-- -->"; // closing "-->" is string
console.log(example);
console.log(document.scripts[0].text);
</script>
</html>
Result in attached file, but even in this page we see that it's correct. I make some research describing this situation:
https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
https://tc39.es/ecma262/#sec-html-like-comments
Bassicaly explicity using "<!--" and "-->" is safe inside JS string if we don't mix them with <script (will not disturb the script execution).
Actually in Scintilla everything in JS string after "-->" chars (including themselves) are trate as comment. Check this code:
<!DOCTYPE html>
<script>
var example = "--> I'm not comment"; // I'm comment
</script>
</html>
Fixed with https://github.com/ScintillaOrg/lexilla/commit/d387a7516a115bfc7d7b7bceeae59689359bc0bd
similar code still in
case SCE_HJ_SINGLESTRING:} else if ((inScriptType == eNonHtmlScript) && (ch == '-') && (chNext == '-') && (chNext2 == '>')) {SCE_HJ_SINGLESTRING fixed with
https://github.com/ScintillaOrg/lexilla/commit/13507dc3bfe7c958483d5bc348be39d871c42f1c