linkedom icon indicating copy to clipboard operation
linkedom copied to clipboard

`>` inside scripts get escaped.

Open hacknlove opened this issue 2 years ago • 2 comments

> const { DOMParser } = require("linkedom");
undefined
> const parser = new DOMParser();
undefined
> parser.parseFromString(`<html><body><script>(() => {if (5>4) { console.log('hello') }})()</script></body></html>`).toString()
`<?xml version="1.0" encoding="utf-8"?><html><body><script>(() =&gt; {if (5&gt;4) { console.log('hello') }})()</script></body></html>`

It should be () => { and 5>4

I'm using [email protected]

hacknlove avatar Mar 17 '23 15:03 hacknlove

there are nodes where no escape should happen: title, textarea, and script or css, among others ... this keeps coming up and I've no idea why ... will have a look whenever I'll find time

WebReflection avatar Mar 17 '23 16:03 WebReflection

I have a similar problem, but not sure if it's exactly the same. It's also about odd replacements in script tags:

const { document } = parseHTML(`<script>new RegExp('(^something.*$')</script>`)

console.log(document.toString());

prints:

<script>new RegExp('(^something.*/script>)</script>

If it's not the same issue, I'm happy to create a new one ✌️

sdvg avatar Mar 20 '23 12:03 sdvg