Improper Escaping of HTML Comments Containing Code
Closed this issue · 1 comments
crafter999 commented
Describe the bug
When processing HTML comments that include code (e.g., tags), the characters < and > are being improperly escaped, causing the code to render incorrectly.
To Reproduce
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- <link rel="preload" href="/fonts/atkinson-regular.woff" as="font" type="font/woff" crossorigin /> -->
</head>
<body>
</body>
</html>
Expected behavior
I've tested it on different browsers, The comments should remain unchanged but instead we get this:
<!-- <link rel="preload" href="/fonts/atkinson-bold.woff" as="font" type="font/woff" crossorigin /--> -->
Test
import { Window } from "happy-dom";
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- This is a comment -->
<!-- Font preloads -->
<!-- <link rel="preload" href="/fonts/atkinson-regular.woff" as="font" type="font/woff" crossorigin /> -->
</head>
<body>
</body>
</html>`
const window = new Window();
//const parser = new window.DOMParser()
//parser.parseFromString(html,"text/html")
const document = window.document;
document.body.innerHTML = html
console.log(document.body.innerHTML)
capricorn86 commented
Thank you for reporting @crafter999! 🙂
I believe this issue has been fixed now in v16.0.0.