From 4c4a30ec422290b911c7af3c26d6a9037b9f7cc7 Mon Sep 17 00:00:00 2001 From: "vidur%netscape.com" Date: Fri, 17 Sep 1999 06:54:58 +0000 Subject: [PATCH] Further corrections in referrer propagation. git-svn-id: svn://10.0.0.236/trunk@47937 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 21 +++++++++++++++------ mozilla/webshell/src/nsWebShell.cpp | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 88f4aa640ab..f52909c6975 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -2000,7 +2000,9 @@ nsWebShell::DoLoadURL(nsIURI * aUri, nsresult rv = NS_OK; rv = aUri->GetSpec(getter_Copies(urlSpec)); if (NS_FAILED(rv)) return rv; + mURL = urlSpec; + mReferrer = aReferrer; // If it's a normal reload that uses the cache, look at the destination anchor // and see if it's an element within the current document @@ -2123,8 +2125,6 @@ nsWebShell::LoadURI(nsIURI * aUri, CancelRefreshURITimers(); nsXPIDLCString scheme, CUriSpec; - mReferrer = aReferrer; - rv = aUri->GetScheme(getter_Copies(scheme)); if (NS_FAILED(rv)) return rv; rv = aUri->GetSpec(getter_Copies(CUriSpec)); @@ -2135,7 +2135,6 @@ nsWebShell::LoadURI(nsIURI * aUri, nsXPIDLCString spec; rv = aUri->GetSpec(getter_Copies(spec)); if (NS_FAILED(rv)) return rv; - mURL = spec; /* * Before the new page is added to the session history, @@ -2215,7 +2214,8 @@ nsWebShell::LoadURI(nsIURI * aUri, */ // Give web-shell-container right of refusal if (nsnull != mContainer) { - rv = mContainer->WillLoadURL(this, mURL.GetUnicode(), nsLoadURL); + nsAutoString str(spec); + rv = mContainer->WillLoadURL(this, str.GetUnicode(), nsLoadURL); if (NS_FAILED(rv)) { return rv; } @@ -2402,8 +2402,14 @@ NS_IMETHODIMP nsWebShell::Reload(nsLoadFlags aType) nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex); if (nsnull != s) { // XXX What about the post data? - return LoadURL(s->GetUnicode(), nsnull, PR_FALSE, aType); + + // Allocate since mReferrer will change beneath us + PRUnichar* str = mReferrer.ToNewUnicode(); + return LoadURL(s->GetUnicode(), nsnull, PR_FALSE, + aType, 0, nsnull, str); + Recycle(str); } + return NS_ERROR_FAILURE; #else if (mSHist) @@ -3018,9 +3024,12 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, { nsIWebShell* shell = GetTarget(target.GetUnicode()); if (nsnull != shell) { + // Allocate since mURL may change beneath us + PRUnichar* str = mURL.ToNewUnicode(); (void)shell->LoadURL(aURLSpec, aPostDataStream, PR_TRUE, nsIChannel::LOAD_NORMAL, - 0, nsnull, mURL.GetUnicode()); + 0, nsnull, str); + Recycle(str); NS_RELEASE(shell); } } diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 88f4aa640ab..f52909c6975 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -2000,7 +2000,9 @@ nsWebShell::DoLoadURL(nsIURI * aUri, nsresult rv = NS_OK; rv = aUri->GetSpec(getter_Copies(urlSpec)); if (NS_FAILED(rv)) return rv; + mURL = urlSpec; + mReferrer = aReferrer; // If it's a normal reload that uses the cache, look at the destination anchor // and see if it's an element within the current document @@ -2123,8 +2125,6 @@ nsWebShell::LoadURI(nsIURI * aUri, CancelRefreshURITimers(); nsXPIDLCString scheme, CUriSpec; - mReferrer = aReferrer; - rv = aUri->GetScheme(getter_Copies(scheme)); if (NS_FAILED(rv)) return rv; rv = aUri->GetSpec(getter_Copies(CUriSpec)); @@ -2135,7 +2135,6 @@ nsWebShell::LoadURI(nsIURI * aUri, nsXPIDLCString spec; rv = aUri->GetSpec(getter_Copies(spec)); if (NS_FAILED(rv)) return rv; - mURL = spec; /* * Before the new page is added to the session history, @@ -2215,7 +2214,8 @@ nsWebShell::LoadURI(nsIURI * aUri, */ // Give web-shell-container right of refusal if (nsnull != mContainer) { - rv = mContainer->WillLoadURL(this, mURL.GetUnicode(), nsLoadURL); + nsAutoString str(spec); + rv = mContainer->WillLoadURL(this, str.GetUnicode(), nsLoadURL); if (NS_FAILED(rv)) { return rv; } @@ -2402,8 +2402,14 @@ NS_IMETHODIMP nsWebShell::Reload(nsLoadFlags aType) nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex); if (nsnull != s) { // XXX What about the post data? - return LoadURL(s->GetUnicode(), nsnull, PR_FALSE, aType); + + // Allocate since mReferrer will change beneath us + PRUnichar* str = mReferrer.ToNewUnicode(); + return LoadURL(s->GetUnicode(), nsnull, PR_FALSE, + aType, 0, nsnull, str); + Recycle(str); } + return NS_ERROR_FAILURE; #else if (mSHist) @@ -3018,9 +3024,12 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, { nsIWebShell* shell = GetTarget(target.GetUnicode()); if (nsnull != shell) { + // Allocate since mURL may change beneath us + PRUnichar* str = mURL.ToNewUnicode(); (void)shell->LoadURL(aURLSpec, aPostDataStream, PR_TRUE, nsIChannel::LOAD_NORMAL, - 0, nsnull, mURL.GetUnicode()); + 0, nsnull, str); + Recycle(str); NS_RELEASE(shell); } }