IE7/8 cors/index.html response header values have a trailing \r
javadoug opened this issue · comments
I know the cors/index.html file is a template for customization but it might be good to fix this issue for the unsuspecting.
Steps to Reproduce:
Serve cors/index.html response data with rawHeaders that contain \r\n line terminators, for example, response comes from a windows server.
req.getAllResponseHeaders() returns
"Server: Apache-Coyote/1.1\r\nContent-Type: application/json\r\nTransfer-Encoding: chunked\r\nDate: Sat, 27 Apr 2013 16:20:41 GMT\r\n\r\n"
In IE7/8 to see these characters in the debugger, escape(req.getAllResponseHeaders())
. Notice the %0D%0A in the output. The resulting headers object contains values with the %0D trailing each value.
This causes subsequent header value comparisons to fail. Since I was passing json data the error manifest in easyXDM incoming method by evaluating isJsonResp as false causing a string to be passed to my success callback instead of json object.
I changed the reHeader = /([\w-_]+):\s+(.*)\r\n|\r|\n/gm
. Note the `\r\n|\r|\n' order is important.