Skip to content

An issue about String.prototype.replace #726

@NWU-NISL

Description

@NWU-NISL
Version

rhino-1.7.12

Test case
var NISLFuzzingFunc=function (){
    var a = 'test'.replace('e', /^/); 
    print(a); 
    var b = 'test'.replace('e', String(/^/))
    print(b);
};
NISLFuzzingFunc();
Execution steps

java -jar rhino/rhino-1.7.12.jar -debug -version 200 testcase.js

Output
tst
t/^/st
Expected behavior
t/^/st
t/^/st
Description

The ES standard stipulates that when the String.prototype.replace (searchValue, replaceValue) method is executed, if the second parameterreplaceValue is not a function, it should be converted into a string first. rhino seems to be missing this step.

Contributor: @Wen Yi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions