Closed Bug 1290655 Opened 8 years ago Closed 8 years ago

String.prototype.{search, split, replace} should ignore |null| methods

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox47 --- unaffected
firefox48 --- unaffected
firefox49 --- affected
firefox-esr45 --- unaffected
firefox50 --- fixed

People

(Reporter: anba, Assigned: arai)

References

Details

Attachments

(1 file)

Test case 1:
---
r = "a-a".split({[Symbol.split]: null, toString(){ return "-"; }});
print(r);
---

Expected: Prints "a,a"
Actual: Throws TypeError



Test case 2:
---
r = "a-a".search({[Symbol.search]: null, toString(){ return "-"; }});
print(r);
---

Expected: Prints "1"
Actual: Throws TypeError



Test case 3:
---
r = "a-a".replace({[Symbol.replace]: null, toString(){ return "-"; }}, "+");
print(r);
---

Expected: Prints "a+a"
Actual: Throws TypeError
somehow I forgot to use GetMethod for search/replace/split, but was using on match ... :P
try is running: https://treeherder.mozilla.org/#/jobs?repo=try&revision=16e0e6ce4a45
Assignee: nobody → arai.unmht
Blocks: 887016
Status: NEW → ASSIGNED
Comment on attachment 8776296 [details] [diff] [review]
Call GetMethod in String.prototype.{search,replace,split}.

Review of attachment 8776296 [details] [diff] [review]:
-----------------------------------------------------------------

You could check GetMethod "Step 4. If IsCallable(func) is false, throw a TypeError exception." as well.
Attachment #8776296 - Flags: review?(evilpies) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/d7cca89ce49723337bd50dd04fec86f43096560a
Bug 1290655 - Call GetMethod in String.prototype.{search,replace,split}. r=evilpie
https://hg.mozilla.org/mozilla-central/rev/d7cca89ce497
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: