User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:184.108.40.206) Gecko/20060426 Firefox/220.127.116.11 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:18.104.22.168) Gecko/20060426 Firefox/22.214.171.124 When fetching a binary file using XMLHttpRequest, the response contained in responseText is mangled. Characters above 0x7f are translated into U+FFFD, effectively destroying the file. This happens without regard to the content-type or charset specified in the headers. Reproducible: Always Steps to Reproduce: 1. Create an XMLHttpRequest object. 2. Perform a GET on a binary file (a file with octets above 0x7f). 3. Examine the results for the U+FFFD codepoint (which should not be present). See upcoming testcase.
This uses an image from Bugzilla, but all binary files are affected. I originally saw it using a TrueType font file that had been transmitted as text/plain, and the bug persisted even after I changed the content-type to application/octet-stream.
what happens if you use xtp.overrideMimeType("text/plain; charset=ISO-8859-1"); (after open, before send)?
With that coercion, the result is better -- octets with the 0x80 bit set are translated into unicode code points, which (in theory) could be reverse-mapped into the original values. However, this is ugly and should not be necessary. Here's another testcase which lets you try other files, content types, etc. If there's a combination that actually handles binary data, that would be sufficient.
Attachment #221590 - Attachment is obsolete: true
-> enhancement, this doesn't sound like a bug to me
Severity: normal → enhancement
There is plans to make a responseBody property available that contains the raw data received from the server. However it is not yet defined what data type this member will be of. It will hopefully be defined as part of the XHR2 spec, so please voice your opinions there.
Summary: XMLHttpRequest mangles binary data → implement XMLHttpRequest.responseBody
Status: UNCONFIRMED → NEW
Ever confirmed: true
Is typed array (i.e. Uint8Array) usable until ByteArray is defined in ECMA-262 spec?
Implemented as .mozResponseArrayBuffer.
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 572522
You need to log in before you can comment on or make changes to this bug.