The default bug view has changed. See this FAQ.

XMLHttpRequest fails to load local binary files (regression of Bug 305243)

RESOLVED FIXED

Status

()

Core
XML
RESOLVED FIXED
12 years ago
11 years ago

People

(Reporter: Simon Bünzli, Unassigned)

Tracking

({fixed1.8, regression})

1.8 Branch
fixed1.8, regression
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050917 Firefox/1.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050917 Firefox/1.4

Since the checkin of Bug 305243, XMLHttpRequest throws the following errors when
trying to load a local binary file:

Error: not well-formed
Source File: file:///C:/console2.xpi
Line: 1, Column: 3
Source Code:
PK
 ----------
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]"  nsresult: "0x80004005
(NS_ERROR_FAILURE)"  location: "JS frame :: javascript:var r=new
XMLHttpRequest(); r.open("GET", "file:///C:/console2.xpi", false); r.send(null);
r.responseText :: <TOP_LEVEL> :: line 1"  data: no]
 ----------

The first one is a non lethal malformed-xml error which is thrown for every
non-XML file. The second one is somewhat of a hindrance for my Mass Installer
extension.

Reproducible: Always

Steps to Reproduce:
1. Open the JavaScript Console
2. Evaluate the following line:
var r=new XMLHttpRequest(); r.open("GET",
"http://www.haslo.ch/zeniko/software/console2.xpi", false); r.send(null);
r.responseText
3. Download this file (see URL)
4. Evaluate the following line (you'll have to adapt the file path):
var r=new XMLHttpRequest(); r.open("GET", "file:///C:/console2.xpi", false);
r.send(null); r.responseText

Actual Results:  
The first evaluation succeeds without error, the second one results in the
mentioned messages.

Expected Results:  
Both calls have the same result.

The malformed-xml error is thrown for each local non-XML file. The second error
is restricted to binary files. To complete the testcase, evaluate thus the
following line which correctly displays the file's content (change the path to a
non-empty text file):
var r=new XMLHttpRequest(); r.open("GET", "file:///C:/debug.txt", false);
r.send(null); r.responseText

Finally, loading non-local text content throws no error at all (as does loading
non-local binary content):
var r=new XMLHttpRequest(); r.open("GET", "http://www.google.com/", false);
r.send(null); r.responseText
(Reporter)

Updated

12 years ago
OS: Windows XP → All
Hardware: PC → All
Version: Trunk → 1.8 Branch
damn. the 1.8 branch doesn't have bug 293046's patch. (this should work on trunk)

I backed out the patch for Bug 305243 - this regression isn't worth that
feature. also, I'm not sure about the risk of bug 293046's patch.

Checking in extensions/xmlextras/base/src/nsXMLHttpRequest.cpp;
/cvsroot/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp,v  <-- 
nsXMLHttpRequest.cpp
new revision: 1.134.2.2; previous revision: 1.134.2.1
done
Checking in extensions/xmlextras/tests/TestXMLExtras.cpp;
/cvsroot/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp,v  <-- 
TestXMLExtras.cpp
new revision: 1.23.4.2; previous revision: 1.23.4.1
done
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Keywords: fixed1.8, regression
Resolution: --- → FIXED
Wladimir, is bug 293046 something to consider for branch?

Comment 3

12 years ago
Yes, this patch is pretty trivial, it should be safe.
You need to log in before you can comment on or make changes to this bug.