Error interpretting regexp expressions

VERIFIED INVALID

Status

()

Core
JavaScript Engine
VERIFIED INVALID
17 years ago
16 years ago

People

(Reporter: Vicente Salvador, Assigned: rogerl (gone))

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
This html source throws a Javascript exception. This shouldn't:

<html>
<head>
<script>
reg_exp = /\w|\s|[!-/]|[:-@]|[\[-`]|[{-ÿ]/;
</script>
</head>
<body>
</body>
</html>

The exception throwed is:

Error: unterminated character class [
Source File: file:///C:/tmp/test.html
Line: 4, Column: 15
Source Code:
reg_exp = /\w|\s|[!-/]|[:-@]|[\[-`]|[{-ÿ]/;

This sould work because \[ is escaped
(Reporter)

Comment 1

17 years ago
Created attachment 41411 [details]
Test case
This has nothing to do with the \[.  The following throws the same exception:

reg_exp = /[!-/]/;

Escaping the "/" in the character class makes things happy (that is, 

reg_exp = /\w|\s|[!-\/]|[:-@]|[\[-`]|[{-ÿ]/;

has no problems).

Looks invalid to me.... 

Comment 3

17 years ago
Boris is correct. Compare the following:

reg_exp1 = /\w|\s|[!-/]|[:-@]|[\[-`]|[{-ÿ]/;
reg_exp2 = /\w|\s|[!-\/]|[:-@]|[\[-`]|[{-ÿ]/;


In the standalone JS shell:

js> reg_exp1 = /\w|\s|[!-/]|[:-@]|[\[-`]|[{-ÿ]/;
7: unterminated character class [:
7: reg_exp = /\w|\s|[!-/]|[:-@]|[\[-`]|[{-ÿ]/;
7: ..........^


js> reg_exp2 = /\w|\s|[!-\/]|[:-@]|[\[-`]|[{-ÿ]/;
/\w|\s|[!-\/]|[:-@]|[\[-`]|[{-ÿ]/

(WORKS FINE)

Comment 4

17 years ago
Have to mark this one invalid. Vicente, thank you for this report. 
We depend on contributors like you to catch the things that we miss - 
Status: UNCONFIRMED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → INVALID

Comment 5

17 years ago
Marking Verified - 
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.