Closed
Bug 522021
Opened 15 years ago
Closed 15 years ago
"Latin Small Letter I" character wrong code range in regular expressions
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 440926
People
(Reporter: schools_ring, Unassigned)
References
()
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 MRA 5.4 (build 02647) Firefox/3.5.3 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
"Latin Small Letter I" character is Unicode \u0069 and it is rightly detected by string methods such as charCodeAt().
But if used in regular expressions this character is being attributed to some unknowingly high code range above Basic Latin. That leads to very bizarre false positives such as
var re = new RegExp('[\u0100-\uFFFF]+','i')
re.test('h') // false
re.test('i') // ! true
re.test('j') // false
The workaround is to explicitly name "i" in code range based regular expressions like
var re = new RegExp('[[i[\\u0100-\\uFFFF]]','i');
which is awkward but functional.
Reproducible: Always
Steps to Reproduce:
1. go to http://javascript.myplus.org/bugs/i_regexp.html with JavaScript enabled to run the test or use Tools>Error Console to directly paste the following code to evaluate:
window.alert( (new RegExp('[\\u0100-\\uFFFF]+','i')).test('i') )
Actual Results:
RegExp('[\\u0100-\\uFFFF]+','i') reports "Latin Small Letter I" character as being within the range (positive match).
Expected Results:
"Latin Small Letter I" character is Unicode \u0069 and has to be out of the specified range.
This bizarre behavior is common to Gecko as well as to Netscape 4.x and IE 6-8 so must have some wartime origins.
Google Chrome 3.0, Safari 4.0, Opera 10.0 do not expose this bug.
Comment 1•15 years ago
|
||
Reducing the range to
javascript:alert( (new RegExp('[\\u0130-\\u0130]+','i')).test('i') )
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•