Access to binary data from Javascript, Ajax, IE: can the password be read from Javascript (and not VB)?

First of all, I know about this question:

and, in particular, the best answer, http://emilsblog.lerch.org/2009/07/javascript-hacks-using-xhr-to-load.html .

So accessing binary data from Javascript using Firefox (and later versions of Chrome that seem to work too, don't know about Opera). So far, so good. But I still hope to find a way to access binary data with modern IE (ideally IE 6, but at least IE 7+), without using VB. It was mentioned that XHR.messageBody would not work (if it contains null bytes), but I was wondering if this could be enabled with newer versions; or there may be alternative settings that would allow easy access to binary data.

A specific use case for me is access to data returned by a web service that is encoded using a binary data transfer format (including combinations of bytes that are not legal in UTF-8 encoding).

+14
javascript internet-explorer ajax binary-data
Sep 13 '10 at 21:49
source share
4 answers

I think the answer is no, like in this post: how do I access the XHR responseBody (for binary data) from Javascript in IE?

(or: "use VBScript for help")

+1
Sep 16 '10 at 23:11
source share

Well, I found some interesting examples, although not a good solution yet.

One obvious thing I've tried is to play with encodings. There are two obvious things that should really work:

  • Latin-1 (also known as ISO-8859-1): This is a single-byte encoding matching one-on-one with Unicode. Therefore, theoretically, this should be enough to declare the content type "text / plain; charset = ISO-8859-1" and get the character per byte. Alas, due to the idiotic logic of browsers (and even the more idiotic mandate for HTML 5!), Some transcoding takes place, which in a strange way changes the range of control characters (codes 128 - 159). Apparently, this is due to the mandatory assumption that the encoding is really Windows-1252 (why? For some silly reasons .. but that's what it is)
  • UCS-2 is a 2-byte fixed-length encoding that preceded UTF-17; and just breaks 16-bit character codes into 2 bytes. Alas, browsers do not seem to support it.
  • UTF-16 can work theoretically, but there is a problem of surrogate pair characters (0xD800 - 0xDFFF) that are reserved. And if byte pairs that encode these characters are included, corruption occurs.

However: it looks like the conversion for Latin-1 may be reversible, and if so, I'm sure I could use it in the end. All mutations range from 1 byte (0x00 - 0xFF) to larger bytes, and there are no ambiguous comparisons, at least for Firefox. If this is true for other browsers, it will be possible to display the values ​​back and remove the negative effects of automatic transcoding. And this will work for several browsers, including IE (with a warning about the need for something special to handle null values).

Finally, some useful links for data type conversions:

+3
Sep 14 '10 at 1:11
source share

This is possible with IE10 using responseType = arraybuffer or blob. You had to wait a few years ...

http://msdn.microsoft.com/en-us/library/ie/br212474%28v=vs.94%29.aspx

http://msdn.microsoft.com/en-us/library/ie/hh673569%28v=vs.85%29.aspx

+3
Apr 26 '13 at 13:50
source share

You can use a JScript VBArray object to get these bytes in IE (without using VBScript):

var data = new VBArray(xhr.responseBody).toArray();

+2
Dec 02 2018-10-12T00:
source share



All Articles