Bug 724841 - Retain case when sending location bar text to search engine service r=bz

This commit is contained in:
Eric Wong 2012-04-28 18:39:14 -07:00
parent 2959b5c867
commit 2974faa0ea
2 changed files with 33 additions and 21 deletions

View File

@ -3896,6 +3896,10 @@ nsDocShell::LoadURI(const PRUnichar * aURI,
rv = LoadURI(uri, loadInfo, extraFlags, true); rv = LoadURI(uri, loadInfo, extraFlags, true);
// Save URI string in case it's needed later when
// sending to search engine service in EndPageLoad()
mOriginalUriString = uriString;
return rv; return rv;
} }
@ -6355,27 +6359,33 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
if (keywordsEnabled && (kNotFound == dotLoc)) { if (keywordsEnabled && (kNotFound == dotLoc)) {
// only send non-qualified hosts to the keyword server // only send non-qualified hosts to the keyword server
// if (!mOriginalUriString.IsEmpty()) {
// If this string was passed through nsStandardURL by sURIFixup->KeywordToURI(mOriginalUriString,
// chance, then it may have been converted from UTF-8 to
// ACE, which would result in a completely bogus keyword
// query. Here we try to recover the original Unicode
// value, but this is not 100% correct since the value may
// have been normalized per the IDN normalization rules.
//
// Since we don't have access to the exact original string
// that was entered by the user, this will just have to do.
bool isACE;
nsCAutoString utf8Host;
nsCOMPtr<nsIIDNService> idnSrv =
do_GetService(NS_IDNSERVICE_CONTRACTID);
if (idnSrv &&
NS_SUCCEEDED(idnSrv->IsACE(host, &isACE)) && isACE &&
NS_SUCCEEDED(idnSrv->ConvertACEtoUTF8(host, utf8Host)))
sURIFixup->KeywordToURI(utf8Host,
getter_AddRefs(newURI)); getter_AddRefs(newURI));
else }
sURIFixup->KeywordToURI(host, getter_AddRefs(newURI)); else {
//
// If this string was passed through nsStandardURL by
// chance, then it may have been converted from UTF-8 to
// ACE, which would result in a completely bogus keyword
// query. Here we try to recover the original Unicode
// value, but this is not 100% correct since the value may
// have been normalized per the IDN normalization rules.
//
// Since we don't have access to the exact original string
// that was entered by the user, this will just have to do.
bool isACE;
nsCAutoString utf8Host;
nsCOMPtr<nsIIDNService> idnSrv =
do_GetService(NS_IDNSERVICE_CONTRACTID);
if (idnSrv &&
NS_SUCCEEDED(idnSrv->IsACE(host, &isACE)) && isACE &&
NS_SUCCEEDED(idnSrv->ConvertACEtoUTF8(host, utf8Host)))
sURIFixup->KeywordToURI(utf8Host,
getter_AddRefs(newURI));
else
sURIFixup->KeywordToURI(host, getter_AddRefs(newURI));
}
} // end keywordsEnabled } // end keywordsEnabled
} }
@ -8070,6 +8080,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
nsIRequest** aRequest) nsIRequest** aRequest)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
mOriginalUriString.Truncate();
#ifdef PR_LOGGING #ifdef PR_LOGGING
if (gDocShellLeakLog && PR_LOG_TEST(gDocShellLeakLog, PR_LOG_DEBUG)) { if (gDocShellLeakLog && PR_LOG_TEST(gDocShellLeakLog, PR_LOG_DEBUG)) {

View File

@ -848,7 +848,8 @@ private:
nsCOMPtr<nsIAtom> mForcedCharset; nsCOMPtr<nsIAtom> mForcedCharset;
nsCOMPtr<nsIAtom> mParentCharset; nsCOMPtr<nsIAtom> mParentCharset;
nsTObserverArray<nsWeakPtr> mPrivacyObservers; nsTObserverArray<nsWeakPtr> mPrivacyObservers;
PRInt32 mParentCharsetSource; PRInt32 mParentCharsetSource;
nsCString mOriginalUriString;
#ifdef DEBUG #ifdef DEBUG
// We're counting the number of |nsDocShells| to help find leaks // We're counting the number of |nsDocShells| to help find leaks