WebReflection / linkedom

A triple-linked lists based DOM implementation.
https://webreflection.medium.com/linkedom-a-jsdom-alternative-53dd8f699311
ISC License
1.66k stars 80 forks source link

`>` inside scripts get escaped. #199

Open hacknlove opened 1 year ago

hacknlove commented 1 year ago
> 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 linkedom@0.14.25

WebReflection commented 1 year ago

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

sdvg commented 1 year ago

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 ✌️