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

parsing fails for scripts w/ html strings #36

Closed
jonathanong opened this issue Jan 13, 2015 · 5 comments
Closed

parsing fails for scripts w/ html strings #36

jonathanong opened this issue Jan 13, 2015 · 5 comments

Comments

@jonathanong
Copy link

<!DOCTYPE html>
<html>
  <head></head><body><script>
      var a = {
        text: '<script src="asdf"></script>'
      };
  </script></body>
</html>
var parse5 = require('parse5');
var fs = require('fs');

var html = fs.readFileSync('index.html', 'utf8');

var parser = new parse5.Parser();

var document = parser.parse(html);
var html = document.childNodes[1];
var body = html.childNodes[html.childNodes.length - 1];
var script = body.childNodes[0];
var text = script.childNodes[0];
console.log(text.value);
// => '\n      var a = {\n        text: \'<script src="asdf">'

it's parsing the </script> inside the <script> as HTML, messing up the document =/

@domenic
Copy link

domenic commented Jan 13, 2015

I think that's how browsers work; you should check.

@jonathanong
Copy link
Author

Really? Fuck

@aredridel
Copy link

Yup. The canonical 'fix' is to emit <\/script> inside a <script> tag to hide it.

@jonathanong
Copy link
Author

then why is syntax highlighting correct?

</argument>

@inikulin
Copy link
Owner

@jonathanong It may use simple RE-based tokenization, so it basically fails on this piece of code.

43081j pushed a commit to 43081j/parse5 that referenced this issue Dec 28, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…nikulin#36)

Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.7.0 to 5.8.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.8.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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

4 participants