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

RegExp issue with very long attributes #12

Closed
rossj opened this issue Apr 30, 2020 · 1 comment · Fixed by #13
Closed

RegExp issue with very long attributes #12

rossj opened this issue Apr 30, 2020 · 1 comment · Fixed by #13
Labels

Comments

@rossj
Copy link
Contributor

rossj commented Apr 30, 2020

I've ran into a parsing issue with some very long XML attributes. For example, the following will raise a RangeError: Maximum call stack size exceeded while running the Attribute regex:

parseXml(`<a b="${'a'.repeat(9000000)}"/>`);

I was able to avoid the error by slightly relaxing the attribute value parts of the Attribute regex as follows:

[^<&"] | ${exports.Reference} => [^<"]

but this change causes 4 tests to fail that are expecting exceptions from various bad & uses in attribute values.

Perhaps the regexes could be kept strict while avoiding the call stack exception, or perhaps a 2-phase approach could be used where the attribute value is checked for invalid references after being parsed from the overall tag.

@rgrove rgrove added the bug label Apr 30, 2020
@rgrove
Copy link
Owner

rgrove commented Apr 30, 2020

Thanks for reporting this! I haven't investigated the problem or your proposed solution yet, but I'll try to take a look soon. This work will probably align well with the larger investigation I want to do (prompted by your earlier issue #9) into the possibility of relying less on regexes, or at least hardening them to be less fragile in cases like this.

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

Successfully merging a pull request may close this issue.

2 participants