Got "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied" error when accessing missing file:/// with Ajax - shouldn't it be "file not found" instead?

RESOLVED WONTFIX

Status

()

RESOLVED WONTFIX
5 years ago
5 years ago

People

(Reporter: sole, Unassigned)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Created attachment 813088 [details]
test case

I am not sure about the reasoning behind throwing that error, but as a developer I'd find it more useful if the browser told me that the file wasn't there, rather than throwing a "restricted URL" exception :-)

Attaching test case to be tried locally.

I also uploaded it but as it's not local it works correctly:
GET http://people.mozilla.org/~spenades/test_cases/local_restricted_url_404/a-file-that-doesnt-exist.txt

http://people.mozilla.org/~spenades/test_cases/local_restricted_url_404/
This doesn't seem to be a web console bug. The web console simply displays errors that come from other parts in the browser.

Maybe this is a Core bug?
Component: Developer Tools: Console → DOM
Product: Firefox → Core
(Reporter)

Comment 2

5 years ago
Probably. I rely on your infinite wisdom to change components to the proper one, because I am very newbie at that--just did my best at guessing :-)

Thanks for reassigning!
So we land in nsPrincipal::CheckMayLoad which calls NS_RelaxStrictFileOriginPolicy.  This can't get the target file, so can't do basic security checks on it (e.g. whether it's a directory), so it returns false.  Then CheckMayLoad returns NS_ERROR_DOM_BAD_URI, which is what the XMLHttpRequest implementation then has to work with...

I don't think it's worth adding special-cases here to make this look like not a permissions check failure, especially because it _is_ a permissions check failure: linking to local files is only allowed if we know certain information about the file, and we can't get that information for nonexistent files.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.