Closed Bug 209717 Opened 21 years ago Closed 21 years ago

Doc.load fails, when using relative path

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mgalli, Assigned: hjtoi-bugzilla)

Details

Attachments

(2 files)

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.
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
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
Closed: 21 years ago
Resolution: --- → FIXED
Component: DOM: Other → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: