jviereck / regjsparser

Parsing the JavaScript's RegExp in JavaScript.
http://www.julianviereck.de/regjsparser/
BSD 2-Clause "Simplified" License
77 stars 20 forks source link

bail if quantifier iterations out of safe integer range #118

Closed tjenkinson closed 2 years ago

tjenkinson commented 2 years ago

Currently it's possible to get the wrong result if the number of iterations is outside the JS safe range. This makes it bail instead.

An other approach could be adding string versions of the min and max minString/maxString (?) and allowing min and max to be null when outside the range JS can represent? This feels better in that it doesn't cause an error on regex that would be valid but that JS can't represent.

Not sure if this should be considered a breaking change. Depends if getting a number close the actual number, but wrong, should be classed as a bug or not 🤷

tjenkinson commented 2 years ago

/x{9999999999999999999}/ also throws in Firefox.

doesn't for me?

nicolo-ribaudo commented 2 years ago

Ugh, I tested with /x{9999999999999999999}/.test("x".repeat(9999999999999999999)) and the error is from .repeat, sorry :see_no_evil:

jviereck commented 2 years ago

Nice catch, thanks for your contribution. I will wait for #117 to land before drafting a new release.