New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 654450 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

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.
 
*regular
It is valid except with /u flag
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]")?
Cc: sureshkumari@chromium.org
Components: Platform>DevTools
Labels: M-56 OS-Mac OS-Windows
Status: Untriaged (was: Unconfirmed)
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.


win-654450.mp4
795 KB View Download

Comment 5 by alph@chromium.org, Oct 12 2016

Components: -Platform>DevTools Blink>JavaScript>Runtime
Cc: yangguo@chromium.org jgruber@chromium.org
Status: Available (was: Untriaged)
Summary: Regular expressions like /[\d-L]/ should not be valid according to the spec, even in the presence of annex b (was: rugular expressions like /[\d-L]/ should not be valid according to the spec, even in the presence of annex b)
Cc: -jgruber@chromium.org
Owner: jgruber@chromium.org
Status: WontFix (was: Available)
/[\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