diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index b7f52f343a8..1fdb7e5cc89 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -5462,8 +5462,14 @@ nsDocShell::RestoreFromHistory() nsCOMPtr document = do_QueryInterface(domDoc); if (document) { - SetCurrentURI(document->GetDocumentURI(), - document->GetChannel(), PR_TRUE); + // Use the uri from the mLSHE we had when we entered this function + // (which need not match the document's URI if anchors are involved), + // since that's the history entry we're loading. Note that if we use + // origLSHE we don't have to worry about whether the entry in question + // is still mLSHE or whether it's now mOSHE. + nsCOMPtr uri; + origLSHE->GetURI(getter_AddRefs(uri)); + SetCurrentURI(uri, document->GetChannel(), PR_TRUE); } // This is the end of our CreateContentViewer() replacement.