diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 9a26678ed1d..88a2b67707f 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -2202,7 +2202,19 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, convertFileToURL(urlStr, urlSpec); rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull); if (NS_FAILED(rv)) { - // no dice, try more tricks + // keyword failover + // we kick the following cases to the keyword server: + // * starts with a '?' + // * contains a space + // * is a single word (contains no dots or scheme) XXX: this breaks + // intranet host lookups. This latter case needs to be handled by + // dns notifications rather than string interrogation. + if ( (urlStr.FindChar('.') == -1) || (urlStr.First() == '?') || (urlStr.FindChar(' ') > -1) ) { + nsAutoString keywordSpec("keyword:"); + keywordSpec.Append(aURLSpec); + + rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull); + } PRInt32 colon, fSlash = urlSpec.FindChar('/'); PRUnichar port; @@ -3376,54 +3388,6 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus, aWebShell); } - if ( (mDocLoader == loader) && (aStatus == NS_ERROR_UNKNOWN_HOST) ) { - // We need to check for a dns failure in aStatus, but dns failure codes - // aren't proliferated yet. This checks for failure for a host lacking - // "www." and/or ".com" and munges the url acordingly, then fires off - // a new request. - // - // XXX This code may or may not have mem leaks depending on the version - // XXX stdurl that is in the tree at a given point in time. This needs to - // XXX be fixed once we have a solid version of std url in. - char *host = nsnull; - nsString2 hostStr; - rv = aURL->GetHost(&host); - if (NS_FAILED(rv)) return rv; - - hostStr.SetString(host); - nsAllocator::Free(host); - PRInt32 dotLoc = -1; - dotLoc = hostStr.FindChar('.'); - PRBool retry = PR_FALSE; - if (-1 == dotLoc) { - hostStr.Insert("www.", 0, 4); - hostStr.Append(".com"); - retry = PR_TRUE; - } else if ( (hostStr.Length() - dotLoc) == 3) { - hostStr.Insert("www.", 0, 4); - retry = PR_TRUE; - } - - if (retry) { - char *modHost = hostStr.ToNewCString(); - if (!modHost) - return NS_ERROR_OUT_OF_MEMORY; - rv = aURL->SetHost(modHost); - nsAllocator::Free(modHost); - modHost = nsnull; - if (NS_FAILED(rv)) return rv; - char *aSpec = nsnull; - rv = aURL->GetSpec(&aSpec); - if (NS_FAILED(rv)) return rv; - nsString2 newURL(aSpec); - // reload the url - const PRUnichar *spec = newURL.GetUnicode(); - if (spec) { - rv = LoadURL(spec, "view"); - } - } // retry - } // unknown host - } //!mProcessedEndDocumentLoad else { rv = NS_OK; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 9a26678ed1d..88a2b67707f 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -2202,7 +2202,19 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, convertFileToURL(urlStr, urlSpec); rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull); if (NS_FAILED(rv)) { - // no dice, try more tricks + // keyword failover + // we kick the following cases to the keyword server: + // * starts with a '?' + // * contains a space + // * is a single word (contains no dots or scheme) XXX: this breaks + // intranet host lookups. This latter case needs to be handled by + // dns notifications rather than string interrogation. + if ( (urlStr.FindChar('.') == -1) || (urlStr.First() == '?') || (urlStr.FindChar(' ') > -1) ) { + nsAutoString keywordSpec("keyword:"); + keywordSpec.Append(aURLSpec); + + rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull); + } PRInt32 colon, fSlash = urlSpec.FindChar('/'); PRUnichar port; @@ -3376,54 +3388,6 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus, aWebShell); } - if ( (mDocLoader == loader) && (aStatus == NS_ERROR_UNKNOWN_HOST) ) { - // We need to check for a dns failure in aStatus, but dns failure codes - // aren't proliferated yet. This checks for failure for a host lacking - // "www." and/or ".com" and munges the url acordingly, then fires off - // a new request. - // - // XXX This code may or may not have mem leaks depending on the version - // XXX stdurl that is in the tree at a given point in time. This needs to - // XXX be fixed once we have a solid version of std url in. - char *host = nsnull; - nsString2 hostStr; - rv = aURL->GetHost(&host); - if (NS_FAILED(rv)) return rv; - - hostStr.SetString(host); - nsAllocator::Free(host); - PRInt32 dotLoc = -1; - dotLoc = hostStr.FindChar('.'); - PRBool retry = PR_FALSE; - if (-1 == dotLoc) { - hostStr.Insert("www.", 0, 4); - hostStr.Append(".com"); - retry = PR_TRUE; - } else if ( (hostStr.Length() - dotLoc) == 3) { - hostStr.Insert("www.", 0, 4); - retry = PR_TRUE; - } - - if (retry) { - char *modHost = hostStr.ToNewCString(); - if (!modHost) - return NS_ERROR_OUT_OF_MEMORY; - rv = aURL->SetHost(modHost); - nsAllocator::Free(modHost); - modHost = nsnull; - if (NS_FAILED(rv)) return rv; - char *aSpec = nsnull; - rv = aURL->GetSpec(&aSpec); - if (NS_FAILED(rv)) return rv; - nsString2 newURL(aSpec); - // reload the url - const PRUnichar *spec = newURL.GetUnicode(); - if (spec) { - rv = LoadURL(spec, "view"); - } - } // retry - } // unknown host - } //!mProcessedEndDocumentLoad else { rv = NS_OK;