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

html/template: investigate rewriting the JS parser #63371

Open
rolandshoemaker opened this issue Oct 4, 2023 · 0 comments
Open

html/template: investigate rewriting the JS parser #63371

rolandshoemaker opened this issue Oct 4, 2023 · 0 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@rolandshoemaker
Copy link
Member

The JS parser used for contextual escaping is a best effort implementation that implements a subset of the lexical grammar required for our purposes. That said it is rather complex, can be somewhat painful to work with, and diverges in places from the ECMAScript 262 specification.

We should investigate if we can rewrite the parser to produce a token stream using the 262 parsing rules, and apply escaping rules directly to the tokens themselves before rendering them. This would likely be a significant undertaking, but also would likely be significantly simpler to maintain in the long term, making the lives of the Security team in particular somewhat easier.

@rolandshoemaker rolandshoemaker added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

1 participant