From 58e54707b6551e24dc0eec9c5d5ba55e59bcd072 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 28 Apr 2004 20:36:36 +0000 Subject: [PATCH] location.host should be the host the jar was fetched from for jar: URIs. Bug 53124, r=darin, sr=jst, a=asa git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_7_BRANCH@155651 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/base/nsGlobalWindow.h | 5 ++++- mozilla/dom/src/base/nsLocation.cpp | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h index a09495a6ad9..961fbf311b1 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.h +++ b/mozilla/dom/src/base/nsGlobalWindow.h @@ -499,7 +499,10 @@ public: NS_DECL_NSIDOMNSLOCATION protected: - nsresult GetURI(nsIURI** aURL); + // In the case of jar: uris, we sometimes want the place the jar was + // fetched from as the URI instead of the jar: uri itself. Pass in + // PR_TRUE for aGetInnermostURI when that's the case. + nsresult GetURI(nsIURI** aURL, PRBool aGetInnermostURI = PR_FALSE); nsresult GetWritableURI(nsIURI** aURL); nsresult SetURI(nsIURI* aURL); nsresult SetHrefWithBase(const nsAString& aHref, nsIURI* aBase, diff --git a/mozilla/dom/src/base/nsLocation.cpp b/mozilla/dom/src/base/nsLocation.cpp index c2d073d01f3..f6e32ffdc12 100644 --- a/mozilla/dom/src/base/nsLocation.cpp +++ b/mozilla/dom/src/base/nsLocation.cpp @@ -48,6 +48,7 @@ #include "nsCDefaultURIFixup.h" #include "nsIURIFixup.h" #include "nsIURL.h" +#include "nsIJARURI.h" #include "nsIIOService.h" #include "nsIServiceManager.h" #include "nsNetUtil.h" @@ -256,7 +257,7 @@ LocationImpl::FindUsableBaseURI(nsIURI * aBaseURI, nsIDocShell * aParent, nsIURI nsresult -LocationImpl::GetURI(nsIURI** aURI) +LocationImpl::GetURI(nsIURI** aURI, PRBool aGetInnermostURI) { *aURI = nsnull; @@ -277,6 +278,16 @@ LocationImpl::GetURI(nsIURI** aURI) return NS_OK; } + if (aGetInnermostURI) { + nsCOMPtr jarURI(do_QueryInterface(uri)); + while (jarURI) { + jarURI->GetJARFile(getter_AddRefs(uri)); + jarURI = do_QueryInterface(uri); + } + } + + NS_ASSERTION(uri, "nsJARURI screwed up?"); + nsCOMPtr urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); @@ -380,7 +391,7 @@ LocationImpl::GetHost(nsAString& aHost) nsCOMPtr uri; nsresult result; - result = GetURI(getter_AddRefs(uri)); + result = GetURI(getter_AddRefs(uri), PR_TRUE); if (uri) { nsCAutoString hostport; @@ -419,7 +430,7 @@ LocationImpl::GetHostname(nsAString& aHostname) nsCOMPtr uri; nsresult result; - result = GetURI(getter_AddRefs(uri)); + result = GetURI(getter_AddRefs(uri), PR_TRUE); if (uri) { nsCAutoString host; @@ -643,7 +654,7 @@ LocationImpl::GetPort(nsAString& aPort) nsCOMPtr uri; nsresult result = NS_OK; - result = GetURI(getter_AddRefs(uri)); + result = GetURI(getter_AddRefs(uri), PR_TRUE); if (uri) { PRInt32 port;