Closed Bug 477129 Opened 15 years ago Closed 15 years ago

String.replace() with RegExp return wrong matched index with mutibyte (high ascii) character

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED WORKSFORME

People

(Reporter: jodyer, Assigned: daumling)

References

Details

as:
var pattern:RegExp = /9/;
var str:String = "?957";
str.replace(pattern, replaceFunction);

var str2:String = "a957";
str2.replace(pattern, replaceFunction);

function replaceFunction(match:String, index:uint, completeString:String):String
{
trace("String: "+completeString);
trace("match pattern: "+match);
trace("match index: "+index);

return match;
}

Not an injection. Same result on (9r45, 9r115, 10d441)

More info: This example call the String.replace() method with a function as the second parameter. The problem is that the matched index is different when you have a high ascii character before the match pattern. It seems to count one high ascii char as two characters.

Reproduction:
1. Run the code above.

Actual Results:

String: ?957
match pattern: 9
match index: 2

String: a957
match pattern: 9
match index: 1

Expected Results:

String: ?957
match pattern: 9
match index: 1

String: a957
match pattern: 9
match index: 1

 
 
 
Transferred Comments:

Trevor Baker - Tue Jan 27 16:31:04 CST 2009
send to internal review for prioritization


This bug transferred from: http://bugs.adobe.com/jira/browse/ASC-3287
Blocks: AS3_Builtins
I'll take it.
Status: NEW → ASSIGNED
Assignee: nobody → daumling
Tested with the current TR build. Problem is no longer reproducable.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → WORKSFORME
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.