Skip to content
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

> inside scripts get escaped. #199

Open
hacknlove opened this issue Mar 17, 2023 · 2 comments
Open

> inside scripts get escaped. #199

hacknlove opened this issue Mar 17, 2023 · 2 comments

Comments

@hacknlove
Copy link

> 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
Copy link
Owner

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
Copy link

sdvg commented Mar 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants