Error attaching file in Mozilla 24.0

Early code worked fine in all browsers. After updating to the new version of Mozilla, an error occurred. In google, I found only one link about this - https://bugzilla.mozilla.org/show_bug.cgi?id=796850 , and I don’t understand how to get rid of the problems.

TypeError: Cannot convert string to ByteString because the character at index 0 has value 1054 which is greater than 255.
xhr.setRequestHeader("X-File-Name", file.name);

In this code:

....
xhr.open('POST', get_page_url() + '?operation=upload_files');
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", file.name);
xhr.send(file);
...

The file.namenormal Cyrillic filename with the extension.

+4
source share
1 answer

I solved the problem:

xhr.setRequestHeader("X-File-Name", file.name);

Replaced by ..

xhr.setRequestHeader("X-File-Name", unescape(encodeURIComponent(file.name)));
+6
source

All Articles