Remove the ambiguity from the PostScript number regex

`\d+\.?\d*` can split a run of digits in as many ways as it is long, so
it would backtrack polynomially if anything following it could reject.
The optional exponent can't, hence no bug today, but `\d+(?:\.\d*)?`
accepts the same numbers unambiguously.
This commit is contained in:
calixteman 2026-08-04 18:43:58 +02:00
parent e57a46436f
commit 16f5691df7
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F

View File

@ -132,7 +132,7 @@ class Lexer {
this.pos = 0;
this.len = data.length;
// Sticky regexes: set lastIndex before exec() to match at an exact offset.
this._numberPattern = /[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/iy;
this._numberPattern = /[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/iy;
this._identifierPattern = /[a-z]+/y;
}