Doc.load fails, when using relative path

RESOLVED FIXED

Status

()

Core
DOM
RESOLVED FIXED
15 years ago
5 years ago

People

(Reporter: /\/\arcio Galli, Assigned: Heikki Toivonen (remove -bugzilla when emailing directly))

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

3.54 KB, application/octet-stream
Details
4.95 KB, patch
Christopher Aillon (sabbatical, not receiving bugmail)
: review+
Heikki Toivonen (remove -bugzilla when emailing directly)
: superreview+
Details | Diff | Splinter Review
(Reporter)

Description

15 years ago
The exception File not Found is generated when you try to reuse the same Doc to
load a file that is specified using relative path.  

I will attach the sample testcase which is basically: 

1) Click Link -> Doc.load("dir/something.xml") -> alert box(loaded). 

Click the link first time, it loads fine. Click the link again and note that
does not load the dir/something.xml. Instead, mozilla is trying to load
dir/dir/something.xml.
(Reporter)

Comment 1

15 years ago
Created attachment 125871 [details]
Zip file with the testcase. 

Note this testcase has a file test1.html and dir/file.xml. I also included
dir/dir_rename_to_dir/file.xml. So you can rename and have dir/dir/file.xml and
will be able to see the dir/dir/file.xml loading on the second click.
.
Assignee: bzbarsky → heikki
Created attachment 125977 [details] [diff] [review]
Proposed fix, use the caller's base URI as the base URI in document.load().

Updated

15 years ago
Attachment #125977 - Flags: superreview?(heikki)
Attachment #125977 - Flags: review?(caillon)
Comment on attachment 125977 [details] [diff] [review]
Proposed fix, use the caller's base URI as the base URI in document.load().

>+  // Create a new URI
>+  rv = NS_NewURI(getter_AddRefs(uri), aUrl, charset.get(), baseURI);
>+  if (NS_FAILED(rv)) return rv;


Fix your if blocks...


>+
>+  // Get security manager, check to see if we're allowed to load this URI
>+  nsCOMPtr<nsIScriptSecurityManager> secMan = 
>+           do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
>+  if (NS_FAILED(rv)) return rv;


...and then ...


>+  rv = secMan->CheckConnect(nsnull, uri, "XMLDocument", "load");
>+  if (NS_FAILED(rv)) {
>+    // We need to return success here so that JS will get a proper
>+    // exception thrown later. Native calls should always result in
>+    // CheckConnect() succeeding, but in case JS calls C++ which calls
>+    // this code the exception might be lost.
>+    return NS_OK;
>+  }
>+
>+  SetDocumentURL(uri);
>+  SetBaseURL(uri);
>+
>+  // Store script context, if any, in case we encounter redirect
>+  // (because we need it there)
>+
>+  mScriptContext = callingContext;
> 
>   // Find out if UniversalBrowserRead privileges are enabled - we will
>   // need this in case of a redirect
>   PRBool crossSiteAccessEnabled;
>   rv = secMan->IsCapabilityEnabled("UniversalBrowserRead",
>                                    &crossSiteAccessEnabled);
>   if (NS_FAILED(rv)) return rv;


...I will be happy.


> 
>   mCrossSiteAccessEnabled = crossSiteAccessEnabled;
Attachment #125977 - Flags: review?(caillon) → review+
Attachment #125977 - Flags: superreview?(heikki-bugzilla) → superreview+
FIXED.
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
Component: DOM: Other → DOM
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.