Closed Bug 223451 Opened 21 years ago Closed 21 years ago

Unescaped, unbalanced parens in a regexp should cause SyntaxError

Categories

(Rhino Graveyard :: Core, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: pschwartau, Assigned: igor)

Details

(Whiteboard: [ compare bug 223273 against SpiderMonkey ])

Attachments

(1 file)

Unescaped, unbalanced parens in a regexp should cause a SyntaxError. The same should also be true for unescaped, unbalanced brackets or braces. This is the Rhino version of bug 223273 against SpiderMonkey. There is a testcase for this at mozilla/js/tests/ecma_3/RegExp/regress-223273.js It is currently failing in the Rhino shell -
> The same should also be true for unescaped, unbalanced brackets or braces. Yes, to be fully ECMA-compliant. However, this differs from Perl, and SpiderMonkey has decided to go with Perl for backward compatibility. Rhino might wish to do the same. See bug 223273 comment 29 and following -
Changing summary: from: "Unescaped, unbalanced parens in a regexp should cause SyntaxError" to: "Allow unescaped, unbalanced parens in a regexp?" This reflects what SpiderMonkey decided to do. If Rhino wants to remain in sync with SpiderMonkey and Perl, it should do the same, even though this is not ECMA-correct.
Summary: Unescaped, unbalanced parens in a regexp should cause SyntaxError → Allow unescaped, unbalanced parens in a regexp?
Whiteboard: [ compare bug 223273 against SpiderMonkey ]
OOPS! Changing summary back to: "Unescaped, unbalanced parens in a regexp should cause SyntaxError" I got mixed up - unescaped, unbalanced parens SHOULD cause a SyntaxError. Where SpiderMonkey and Perl deviate from ECMA is in the treatment of unescaped, unbalanced right-brackets, and braces (both left and right). The testcase above is failing in Rhino in two different sections: 1. Unescaped, unbalanced right-parens are not generating a SyntaxError. They should. (Sections 2, 4 of the above test). 2. Unescaped, unbalanced braces (left and right) are generating SyntaxErrors They should if Rhino wants to be in sync with SpiderMonkey and Perl instead of ECMA. (Sections 21-24 of the above test).
Summary: Allow unescaped, unbalanced parens in a regexp? → Unescaped, unbalanced parens in a regexp should cause SyntaxError
Typo above: > Unescaped, unbalanced braces (left and right) are generating SyntaxErrors. > They should if Rhino wants to be in sync with SpiderMonkey and Perl They should NOT if Rhino wants to be in sync with SpiderMonkey and Perl -
Check for unbalanced ')' is done differently then in SM since rhino uses recursive version of SM code while fix for ArrayIndexOutOfBoundsException is just a variation of my patch for bug 227705 in SM.
The above ArrayIndexOutOfBoundsException is trivially triggered in Rhino with the following regexp: /(?/ as in : js> /(?/ Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at org.mozilla.javascript.regexp.NativeRegExp.parseTerm(NativeRegExp.jav
Assigning to self
Assignee: nboyd → igor
I committed the fix
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
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.

Attachment

General

Creator:
Created:
Updated:
Size: