Sth goes wrong when excuting window.fetch witch 'headers' after extending Object.prototype with line-break.
Reported by
o...@mug.dog,
Sep 14 2016
|
||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Steps to reproduce the problem:
1. Open the console
2. Type the code
```
Object.prototype.foo = function () {}
fetch('/', {method: 'POST', headers: {}})
```
3. All going well.
4. Type the code
```
Object.prototype.foo = function () {
}
fetch('/', {method: 'POST', headers: {}})
```
5. Throwing an error:
```
TypeError: Failed to execute 'fetch' on 'Window': Invalid value
```
What is the expected behavior?
It should works well whether line-break exsists.
What went wrong?
When extending Object.prototype with line-break, the fetch API with POST method and headers goes wrong.
Did this work before? N/A
Chrome version: 52.0.2743.116 Channel: n/a
OS Version: OS X 10.11.6
Flash Version: Shockwave Flash 22.0 r0
,
Sep 14 2016
dgozman@ any idea why this is different?
,
Sep 14 2016
Played with this. Using "headers: {__proto__: null}" makes everything work, so the problem is definitely with the headers being enumerated.
I'm surprised that "foo" from the prototype is even used here.
@kozyatinskiy, yhirano: any thoughts?
,
Sep 14 2016
Because String(headers.foo) includes a line-break and HTTP doesn't allow it. See https://fetch.spec.whatwg.org/#concept-headers-fill.
,
Sep 14 2016
Thanks for clarification. Sounds like this is according to the spec. I still think that grabbing properties from a prototype is somewhat counter-intuitive, but spec is a spec. |
||||
►
Sign in to add a comment |
||||
Comment 1 by o...@mug.dog
, Sep 14 2016