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
This commit is contained in:
bzbarsky%mit.edu
2004-04-28 20:36:36 +00:00
parent 14bf24e346
commit 58e54707b6
2 changed files with 19 additions and 5 deletions

View File

@@ -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,

View File

@@ -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<nsIJARURI> jarURI(do_QueryInterface(uri));
while (jarURI) {
jarURI->GetJARFile(getter_AddRefs(uri));
jarURI = do_QueryInterface(uri);
}
}
NS_ASSERTION(uri, "nsJARURI screwed up?");
nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
@@ -380,7 +391,7 @@ LocationImpl::GetHost(nsAString& aHost)
nsCOMPtr<nsIURI> 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<nsIURI> 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<nsIURI> uri;
nsresult result = NS_OK;
result = GetURI(getter_AddRefs(uri));
result = GetURI(getter_AddRefs(uri), PR_TRUE);
if (uri) {
PRInt32 port;