-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Handling of "<" and ">" in Script Comments (DOMParser and Window) #1564
Comments
This is quite a major problem - it breaks css / scripts. @capricorn86 I think the issue comes from XMLSerializer escaping all text even in CSS / Script context, there should be a css / script aware escape or no escape at all.
|
Also rendering of links is affected: |
@Slimacik I just tested your code in the developer consoles of Firefox and Chrome. Both consoles produced the same output as Happy DOM, so the behavior you are describing seems to be correct. |
There was a fix related to this in v15.10.5. Does the problem still exists? |
@capricorn86 I just tested with v15.10.5 as well as v15.11.6. My tests failed with both versions as link's href contains It works with v14.12.3 though |
@cf-amin-aoulkadi Can you describe how did you tested it please? I just executed lines below in Chrome's dev. console and got href with Executed lines:
|
@Slimacik I simply ran this code from your first comment in the developer console ... new DOMParser().parseFromString("<a href='/test?at1=val1&at2=val2'>Link</a>", "text/html").body.innerHTML ... and the browser returned |
The problem I initially reported ( However, 15.10.5 basically flipped the problem around: Now Reproductionnew DOMParser().parseFromString("<div><script>//<><></script></div>", "text/html").body.outerHTML Expected Result (Firefox / Chrome): |
@cf-amin-aoulkadi You are right, thank you! I did not realised that link in innerHTML can be different than value retrieved by href attribute, and it worked with previous versions of happy dom. |
Describe the bug
If a
<script>
element contains a JavaScript comment (see example below),<
and>
characters within that comment are converted to<
and>
by Happy DOM. This should not happen.Example:
To Reproduce
DOMParser
provided by Happy DOM://<><>
has been converted to//<><>
.I have also seen this happen when setting
window.document.body.innerHTML
of a Happy DOMWindow
.Expected behavior
Firefox and Chrome developer consoles generate the following output:
Device:
mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye
dev container)Additional context
I am using Happy DOM with Vitest.
This is my Happy DOM
Window
configuration:The text was updated successfully, but these errors were encountered: