jpillora / xdomain

A pure JavaScript CORS alternative
https://jpillora.com/xdomain/
3.12k stars 269 forks source link

Safari 9 OSX: "DOM Exception 12: An invalid or illegal string was specified." #172

Closed sekmun closed 8 years ago

sekmun commented 8 years ago

I'm seeing this in Safari 9 OSX:

SyntaxError: DOM Exception 12: An invalid or illegal string was specified.
setRequestHeaderxdomain.min.js:2:5249
hxdomain.min.js:2:5249
gxdomain.min.js:2:5687
sendxdomain.min.js:2:5691
(anonymous function)xdomain.min.js:2:9589
dxdomain.min.js:2:1940
(anonymous function)xdomain.min.js:2:1737
(anonymous function)xdomain.min.js:2:11216

Seems to be related to an older problem, anyone else seeing this? thanks

sekmun commented 8 years ago

on 469: when setting Authorization there is a trailing space for "Basic" (ie, "Basic")... I just added a .trim() to value, so

470: xhr.setRequestHeader(header, value.trim());

Not sure if that would break stuff? Why would there be a trailing space for Safari?!!

jpillora commented 8 years ago

Thanks for debugging @sekmun, I just pasted this into the safari console:

//invalid authorization format?
var x = new XMLHttpRequest(); x.open("GET", "foo"); x.setRequestHeader("Authorization", " Basic foo"); x.onload = console.info.bind(console, x); x.send();

and it triggers a Error: SyntaxError: DOM Exception 12 so it looks like it's not an XDomain issue. I'll close, you can reopen if you find anything else :)