-
Notifications
You must be signed in to change notification settings - Fork 80
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
Text escaping of $& becomes >< #158
Comments
what's |
Sorry, that was just an example since In my SSR I first run the app and then use import { parseHTML } from "https://esm.sh/linkedom"
const { document } = parseHTML('<script>var $=1;$&&true</script>')
console.log(document.toString()) Output: |
those are two different code paths/logic ... one thing is the toString actuallt escape chars, don't drop these https://github.com/WebReflection/linkedom/blob/main/esm/interface/text.js#L41 |
I'm sorry, I don't quite understand what you mean. Do you mean that it's not reproducible with the code I gave or that it isn't a bug?
I don't know, but it seems to me like both code paths produce the same (seemingly wrong) output. If they are completely different code-paths then it would seem that they both have the same bug.
Sorry, I don't understand what you mean? If it helps to clarify it seems to only happen with script elements, for example this does both textContent and html parsing for both script elements and divs, and it only seems to produce the bug with the script elements (and there does it for both): import { parseHTML } from "https://esm.sh/linkedom"
const { document } = parseHTML('<script>$&</script><script class="t"></script><div>$&</div><div class="t2"></div>')
document.querySelector(".t").textContent = '$&'
document.querySelector(".t2").textContent = '$&'
console.log(document.toString()) output: |
Hello!
I think I have found a slight issue with how text is escaped. using this code:
logs
<script>var $=1;><&true</script>
as output.$&
has been replaced by><
.If I run similar code in a browser I get
<script>var $=1;$&&true</script>
. The code I ran in the browser isThis is a bit problematic for me since it means that inlineing my JS after SSR produces invalid code which will not run.
I have tested it in deno (v1.24.3), node (v18.2.0) and bun.sh (v0.1.11) so I don't think it's anything platform specific.
Thanks!
The text was updated successfully, but these errors were encountered: