зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1439931 - nsIIOService.extractScheme/net_ExtractURLScheme should lowercase its output r=mayhemer
MozReview-Commit-ID: LZ2rqIdIoXQ --HG-- extra : rebase_source : 3d9973f0001ddc2d98cad0ddddb646cedac489c7
This commit is contained in:
Родитель
90a323afe9
Коммит
a60ce32b46
|
@ -6076,7 +6076,7 @@ function stripUnsafeProtocolOnPaste(pasteData) {
|
|||
try {
|
||||
scheme = Services.io.extractScheme(pasteData);
|
||||
} catch (ex) { }
|
||||
if (scheme.toLowerCase() != "javascript") {
|
||||
if (scheme != "javascript") {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI,
|
|||
// after it. The easiest way to do that is to call this method again with the
|
||||
// "view-source:" lopped off and then prepend it again afterwards.
|
||||
|
||||
if (scheme.LowerCaseEqualsLiteral("view-source")) {
|
||||
if (scheme.EqualsLiteral("view-source")) {
|
||||
nsCOMPtr<nsIURIFixupInfo> uriInfo;
|
||||
// We disable keyword lookup and alternate URIs so that small typos don't
|
||||
// cause us to look at very different domains
|
||||
|
@ -177,7 +177,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI,
|
|||
innerURIString.Trim(" ");
|
||||
nsAutoCString innerScheme;
|
||||
ioService->ExtractScheme(innerURIString, innerScheme);
|
||||
if (innerScheme.LowerCaseEqualsLiteral("view-source")) {
|
||||
if (innerScheme.EqualsLiteral("view-source")) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -233,47 +233,47 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI,
|
|||
if (sFixTypos && (aFixupFlags & FIXUP_FLAG_FIX_SCHEME_TYPOS)) {
|
||||
// Fast-path for common cases.
|
||||
if (scheme.IsEmpty() ||
|
||||
scheme.LowerCaseEqualsLiteral("http") ||
|
||||
scheme.LowerCaseEqualsLiteral("https") ||
|
||||
scheme.LowerCaseEqualsLiteral("ftp") ||
|
||||
scheme.LowerCaseEqualsLiteral("file")) {
|
||||
scheme.EqualsLiteral("http") ||
|
||||
scheme.EqualsLiteral("https") ||
|
||||
scheme.EqualsLiteral("ftp") ||
|
||||
scheme.EqualsLiteral("file")) {
|
||||
// Do nothing.
|
||||
} else if (scheme.LowerCaseEqualsLiteral("ttp")) {
|
||||
} else if (scheme.EqualsLiteral("ttp")) {
|
||||
// ttp -> http.
|
||||
uriString.ReplaceLiteral(0, 3, "http");
|
||||
scheme.AssignLiteral("http");
|
||||
info->mFixupChangedProtocol = true;
|
||||
} else if (scheme.LowerCaseEqualsLiteral("htp")) {
|
||||
} else if (scheme.EqualsLiteral("htp")) {
|
||||
// htp -> http.
|
||||
uriString.ReplaceLiteral(0, 3, "http");
|
||||
scheme.AssignLiteral("http");
|
||||
info->mFixupChangedProtocol = true;
|
||||
} else if (scheme.LowerCaseEqualsLiteral("ttps")) {
|
||||
} else if (scheme.EqualsLiteral("ttps")) {
|
||||
// ttps -> https.
|
||||
uriString.ReplaceLiteral(0, 4, "https");
|
||||
scheme.AssignLiteral("https");
|
||||
info->mFixupChangedProtocol = true;
|
||||
} else if (scheme.LowerCaseEqualsLiteral("tps")) {
|
||||
} else if (scheme.EqualsLiteral("tps")) {
|
||||
// tps -> https.
|
||||
uriString.ReplaceLiteral(0, 3, "https");
|
||||
scheme.AssignLiteral("https");
|
||||
info->mFixupChangedProtocol = true;
|
||||
} else if (scheme.LowerCaseEqualsLiteral("ps")) {
|
||||
} else if (scheme.EqualsLiteral("ps")) {
|
||||
// ps -> https.
|
||||
uriString.ReplaceLiteral(0, 2, "https");
|
||||
scheme.AssignLiteral("https");
|
||||
info->mFixupChangedProtocol = true;
|
||||
} else if (scheme.LowerCaseEqualsLiteral("htps")) {
|
||||
} else if (scheme.EqualsLiteral("htps")) {
|
||||
// htps -> https.
|
||||
uriString.ReplaceLiteral(0, 4, "https");
|
||||
scheme.AssignLiteral("https");
|
||||
info->mFixupChangedProtocol = true;
|
||||
} else if (scheme.LowerCaseEqualsLiteral("ile")) {
|
||||
} else if (scheme.EqualsLiteral("ile")) {
|
||||
// ile -> file.
|
||||
uriString.ReplaceLiteral(0, 3, "file");
|
||||
scheme.AssignLiteral("file");
|
||||
info->mFixupChangedProtocol = true;
|
||||
} else if (scheme.LowerCaseEqualsLiteral("le")) {
|
||||
} else if (scheme.EqualsLiteral("le")) {
|
||||
// le -> file.
|
||||
uriString.ReplaceLiteral(0, 2, "file");
|
||||
scheme.AssignLiteral("file");
|
||||
|
|
|
@ -196,7 +196,7 @@ interface nsIIOService : nsISupports
|
|||
* is provided purely as an optimization.
|
||||
*
|
||||
* @param aSpec the URL string to parse
|
||||
* @return URL scheme
|
||||
* @return URL scheme, lowercase
|
||||
*
|
||||
* @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
|
||||
*/
|
||||
|
|
|
@ -296,7 +296,6 @@ nsSimpleURI::SetSpecInternal(const nsACString &aSpec)
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
ToLowerCase(mScheme);
|
||||
|
||||
nsAutoCString spec;
|
||||
rv = net_FilterAndEscapeURI(aSpec, esc_OnlyNonASCII, spec);
|
||||
|
|
|
@ -525,6 +525,7 @@ net_ExtractURLScheme(const nsACString &inURI,
|
|||
|
||||
p.Claim(scheme);
|
||||
scheme.StripTaggedASCII(ASCIIMask::MaskCRLFTab());
|
||||
ToLowerCase(scheme);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ bool net_IsAbsoluteURL(const nsACString& inURL);
|
|||
* Extract URI-Scheme if possible
|
||||
*
|
||||
* @param inURI URI spec
|
||||
* @param scheme scheme copied to this buffer on return (may be null)
|
||||
* @param scheme scheme copied to this buffer on return. Is lowercase.
|
||||
*/
|
||||
nsresult net_ExtractURLScheme(const nsACString &inURI,
|
||||
nsACString &scheme);
|
||||
|
|
|
@ -57,7 +57,7 @@ nsViewSourceChannel::Init(nsIURI* uri)
|
|||
return rv;
|
||||
|
||||
// prevent viewing source of javascript URIs (see bug 204779)
|
||||
if (scheme.LowerCaseEqualsLiteral("javascript")) {
|
||||
if (scheme.EqualsLiteral("javascript")) {
|
||||
NS_WARNING("blocking view-source:javascript:");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
ChromeUtils.import('resource://gre/modules/Services.jsm');
|
||||
|
||||
add_task(function test_extractScheme(){
|
||||
equal(Services.io.extractScheme("HtTp://example.com"), "http");
|
||||
Assert.throws(() => { Services.io.extractScheme("://example.com"); },
|
||||
/NS_ERROR_MALFORMED_URI/, "missing scheme");
|
||||
Assert.throws(() => { Services.io.extractScheme("ht%tp://example.com"); },
|
||||
/NS_ERROR_MALFORMED_URI/, "bad scheme");
|
||||
});
|
|
@ -418,3 +418,4 @@ run-sequentially = node server exceptions dont replay well
|
|||
[test_trr.js]
|
||||
# http2-using tests require node available
|
||||
skip-if = os == "android"
|
||||
[test_ioservice.js]
|
||||
|
|
|
@ -1680,7 +1680,7 @@ nsAutoCompleteController::CompleteValue(nsString &aValue)
|
|||
const int32_t findIndex = 7; // length of "http://"
|
||||
|
||||
if ((endSelect < findIndex + mSearchStringLength) ||
|
||||
!scheme.LowerCaseEqualsLiteral("http") ||
|
||||
!scheme.EqualsLiteral("http") ||
|
||||
!Substring(aValue, findIndex, mSearchStringLength).Equals(
|
||||
mSearchString, nsCaseInsensitiveStringComparator())) {
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче