Regular expressions like /[\d-L]/ should not be valid according to the spec, even in the presence of annex b
Reported by
neni.on...@gmail.com,
Oct 10 2016
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0
Steps to reproduce the problem:
1. "5-L".match(/[\d-L]/g)
2.
3.
What is the expected behavior?
It should actually raise a SyntaxError, because the calculated charset for the start and end of a ClassRange must have a length of 1 (which is not the case for \d)
What went wrong?
Looks like the current implementation treats /[\d-L]/ as valid, parsing it as if it were a regex composed of a single ClassRange comprising a ClassEscape('d'), a ClassAtom('-'), and a ClassAtom('L'); thus "5-L".match(/[\d-L]/g) returns ["5", "-", "L"]
Did this work before? N/A
Chrome version: 53.0.2785.116 (64-bit) Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
I have tried as hard as I could afford to find a derivation, starting from the "Pattern" goal,that would lead to /[\d-L]/; but I couldn't. It might be that I have missed something in the spec, but if it's not the cause, this is a bug in chrome.
,
Oct 11 2016
It is valid except with /u flag
,
Oct 11 2016
I'm not sure about its validity -- how is it derived from the spec's "Pattern" goal,i.e, what is the sequence of productions that connect "Pattern" to "[\d-L]")?
,
Oct 12 2016
Tested on Windows-10, Mac-10.11.6 and Linux ubuntu-14.04 with chrome stable versions 53.0.2785.116 and 53.0.2785.143 and canary 56.0.2887.0. Able to reproduce the issue. observed that it is not raising a syntax error which giving in other (Firefox) browser. This is Non-regression issue as it is observed from earlier version of chrome 30.0.1549.0 and marking it as untraiged to get more inputs from dev team.
,
Oct 12 2016
,
Oct 13 2016
,
Apr 4 2017
/[\d-L]/ is valid RegExp syntax according to Annex B. ClassAtom[?U] - ClassAtom[?U] ClassRanges[?U] When the first ClassAtom does not evaluate to exactly one character, CharacterRangeOrUnion returns the union of both ClassAtoms, ClassRanges, and '-'. See https://tc39.github.io/ecma262/#prod-annexB-NonemptyClassRanges. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by neni.on...@gmail.com
, Oct 10 2016