mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 14:46:02 +00:00
Bug 1047600 - duff protocol should never keyword search, r=smaug
--HG-- extra : rebase_source : 602b5f9c89ede5e717658ad21e698260c2e2f808
This commit is contained in:
parent
debaee9a8d
commit
415e2f4067
@ -344,6 +344,22 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
|
||||
// Fix up protocol string before calling KeywordURIFixup, because
|
||||
// it cares about the hostname of such URIs:
|
||||
nsCOMPtr<nsIURI> uriWithProtocol;
|
||||
bool inputHadDuffProtocol = false;
|
||||
|
||||
// Prune duff protocol schemes
|
||||
//
|
||||
// ://totallybroken.url.com
|
||||
// //shorthand.url.com
|
||||
//
|
||||
if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("://")))
|
||||
{
|
||||
uriString = StringTail(uriString, uriString.Length() - 3);
|
||||
inputHadDuffProtocol = true;
|
||||
} else if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("//"))) {
|
||||
uriString = StringTail(uriString, uriString.Length() - 2);
|
||||
inputHadDuffProtocol = true;
|
||||
}
|
||||
|
||||
// NB: this rv gets returned at the end of this method if we never
|
||||
// do a keyword fixup after this (because the pref or the flags passed
|
||||
// might not let us).
|
||||
@ -354,7 +370,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
|
||||
|
||||
// See if it is a keyword
|
||||
// Test whether keywords need to be fixed up
|
||||
if (sFixupKeywords && (aFixupFlags & FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP)) {
|
||||
if (sFixupKeywords && (aFixupFlags & FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP) &&
|
||||
!inputHadDuffProtocol) {
|
||||
KeywordURIFixup(uriString, info, aPostData);
|
||||
if (info->mPreferredURI)
|
||||
return NS_OK;
|
||||
@ -728,20 +745,6 @@ nsDefaultURIFixup::FixupURIProtocol(const nsACString & aURIString,
|
||||
nsAutoCString uriString(aURIString);
|
||||
*aURI = nullptr;
|
||||
|
||||
// Prune duff protocol schemes
|
||||
//
|
||||
// ://totallybroken.url.com
|
||||
// //shorthand.url.com
|
||||
//
|
||||
if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("://")))
|
||||
{
|
||||
uriString = StringTail(uriString, uriString.Length() - 3);
|
||||
}
|
||||
else if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("//")))
|
||||
{
|
||||
uriString = StringTail(uriString, uriString.Length() - 2);
|
||||
}
|
||||
|
||||
// Add ftp:// or http:// to front of url if it has no spec
|
||||
//
|
||||
// Should fix:
|
||||
|
@ -65,8 +65,10 @@ let testcases = [
|
||||
|
||||
if (Services.appinfo.OS.toLowerCase().startsWith("win")) {
|
||||
testcases.push(["C:\\some\\file.txt", "file:///C:/some/file.txt", null, false, true]);
|
||||
testcases.push(["//mozilla", "http://mozilla/", "http://www.mozilla.com/", false, true]);
|
||||
} else {
|
||||
testcases.push(["/some/file.txt", "file:///some/file.txt", null, false, true]);
|
||||
testcases.push(["//mozilla", "file:////mozilla", null, false, true]);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user