« Bugzilla Issues Index
#3472 — 19.1.3.6 Object.prototype.toString: Possible to detect proxied array objects
- bug_id:
3472
- creation_ts:
2014-12-17 13:59:00 -0800
- short_desc:
19.1.3.6 Object.prototype.toString: Possible to detect proxied array objects
- delta_ts:
2014-12-23 20:23:31 -0800
- product:
Draft for 6th Edition
- component:
technical issue
- version:
Rev 29: December 06, 2014 Draft
- rep_platform:
All
- op_sys:
All
- bug_status:
RESOLVED
- resolution:
FIXED
- priority:
Normal
- bug_severity:
normal
- everconfirmed:
true
- reporter:
André Bargull
- assigned_to:
Allen Wirfs-Brock
- cc:
["erights", "erights", "tomvc.be"]
- commentid:
11075
- comment_count:
0
- who:
André Bargull
- bug_when:
2014-12-17 13:59:17 -0800
19.1.3.6 Object.prototype.toString ( )
Object.prototype.toString possibly needs to use IsArray, otherwise it can be (ab-)used to detect proxied array objects, because it's not possible for proxied array objects to use the tag "Array".
---
js> p = new Proxy([], {
get(t,pk,r){
if(pk === Symbol.toStringTag) return "Array";
return Reflect.get(t,pk,r)
}})
{}
js> Array.isArray(p)
true
js> Object.prototype.toString.call(p)
"[object ~Array]"
---
- commentid:
11079
- comment_count:
1
- who:
Allen Wirfs-Brock
- bug_when:
2014-12-17 16:34:32 -0800
Mark/Tom are you ok if we make this change? I don't really like it, as it allows a Proxy that expose no array behavior to still claim to be a built-in Array. But give that we agreed to make Array.isArray work in this manner I don't see why we wouldn't also do it for O.p.toString.
- commentid:
11091
- comment_count:
2
- who:
Mark Miller
- bug_when:
2014-12-17 20:11:03 -0800
Yes, I think that is the most consistent thing to do.
- commentid:
11106
- comment_count:
3
- who:
Allen Wirfs-Brock
- bug_when:
2014-12-18 09:06:41 -0800
fixed in rev30 editor's draft
- commentid:
11127
- comment_count:
4
- who:
Tom Van Cutsem
- bug_when:
2014-12-21 11:13:25 -0800
+1
- commentid:
11197
- comment_count:
5
- who:
Allen Wirfs-Brock
- bug_when:
2014-12-23 20:23:31 -0800
fixed in rev30