bug with braces in JavaScript regular expressions

RESOLVED FIXED in 1.5R5

Status

Rhino
Core
RESOLVED FIXED
15 years ago
15 years ago

People

(Reporter: Phil Schwartau, Assigned: Igor Bukanov)

Tracking

Details

(Whiteboard: [ Rhino version of bug 228087 against SpiderMonkey ])

Attachments

(1 attachment)

(Reporter)

Description

15 years ago
This is the Rhino version of bug 228087 against SpiderMonkey.
The following regexp patterns are causing SyntaxErrors:

js> re = /{1.*}/g;
js: uncaught JavaScript exception: SyntaxError: Invalid quantifier {

js> re = /{1[.!}]*}/g;
js: uncaught JavaScript exception: SyntaxError: Invalid quantifier {


This is correct per ECMA-262 Ed. 3, which prohibits the use of unescaped
braces in regexp patterns unless they form part of a quantifier.

However, as part of the SpiderMonkey RegExp rewrite (bug 85721), it was
decided to follow Perl and IE, and allow unescaped braces even if they
are not part of a quantifier.

See bug 188206 comment 12; also bug 223273 comment 29 and following.

It looks like the RegExp parser is mistakenly identifying the above
use of braces as quantifiers (hence the SyntaxErrors), instead of
the non-quantifier, literal use of unescaped braces that we permit.

The testcase for this bug is 

      mozilla/js/tests/ecma_3/RegExp/regress-228087.js

It is currently failing in both the SpiderMonkey and Rhino shells -
(Reporter)

Updated

15 years ago
Whiteboard: [ Rhino version of bug 228087 against SpiderMonkey ]
(Assignee)

Comment 1

15 years ago
I will look at it
Assignee: nboyd → igor
(Assignee)

Comment 2

15 years ago
Created attachment 139194 [details] [diff] [review]
Fix: Perl-compatible handling of {} and overflow checks in regexps

This is a Rhino version of Brandan's patch from attachment 138844 [details] [diff] [review], bug 228087
plus code to fix overflow problem reported in bug 230216.
(Assignee)

Comment 3

15 years ago
I committed the fix
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
(Assignee)

Comment 4

15 years ago
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.