зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1643093 - Remove references to 'whitelist' in browser/components/urlbar. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D78122
This commit is contained in:
Родитель
f1e15241c4
Коммит
3d209f79ac
|
@ -193,7 +193,7 @@ pref("browser.uitour.surveyDuration", 7200);
|
||||||
pref("keyword.enabled", true);
|
pref("keyword.enabled", true);
|
||||||
// Fixup whitelists, the urlbar won't try to search for these words, but will
|
// Fixup whitelists, the urlbar won't try to search for these words, but will
|
||||||
// instead consider them valid TLDs. Don't check these directly, use
|
// instead consider them valid TLDs. Don't check these directly, use
|
||||||
// Services.uriFixup.isDomainWhitelisted() instead.
|
// Services.uriFixup.isDomainKnown() instead.
|
||||||
pref("browser.fixup.domainwhitelist.localhost", true);
|
pref("browser.fixup.domainwhitelist.localhost", true);
|
||||||
// https://tools.ietf.org/html/rfc2606
|
// https://tools.ietf.org/html/rfc2606
|
||||||
pref("browser.fixup.domainsuffixwhitelist.test", true);
|
pref("browser.fixup.domainsuffixwhitelist.test", true);
|
||||||
|
|
|
@ -670,7 +670,7 @@ class UrlbarInput {
|
||||||
) {
|
) {
|
||||||
// When fixing a single word to a search, the docShell also checks the
|
// When fixing a single word to a search, the docShell also checks the
|
||||||
// DNS and asks the user whether they would rather visit that as a
|
// DNS and asks the user whether they would rather visit that as a
|
||||||
// host. On a positive answer, it adds to the domain whitelist that
|
// host. On a positive answer, it adds to the known domain list that
|
||||||
// we use to make decisions. Because we are directly asking for a
|
// we use to make decisions. Because we are directly asking for a
|
||||||
// search here, bypassing the docShell, we need invoke the same check
|
// search here, bypassing the docShell, we need invoke the same check
|
||||||
// ourselves. See also URIFixupChild.jsm and keyword-uri-fixup.
|
// ourselves. See also URIFixupChild.jsm and keyword-uri-fixup.
|
||||||
|
@ -842,8 +842,8 @@ class UrlbarInput {
|
||||||
let { value, selectionStart, selectionEnd } = result.autofill;
|
let { value, selectionStart, selectionEnd } = result.autofill;
|
||||||
this._autofillValue(value, selectionStart, selectionEnd);
|
this._autofillValue(value, selectionStart, selectionEnd);
|
||||||
} else {
|
} else {
|
||||||
// If the url is trimmed but it's invalid (for example it has a non
|
// If the url is trimmed but it's invalid (for example it has an unknown
|
||||||
// whitelisted single word host, or an unknown domain suffix), trimming
|
// single word host, or an unknown domain suffix), trimming
|
||||||
// it would end up executing a search instead of visiting it.
|
// it would end up executing a search instead of visiting it.
|
||||||
let allowTrim = true;
|
let allowTrim = true;
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -104,7 +104,7 @@ var UrlbarTokenizer = {
|
||||||
// having a protocol.
|
// having a protocol.
|
||||||
let slashIndex = token.indexOf("/");
|
let slashIndex = token.indexOf("/");
|
||||||
let prePath = slashIndex != -1 ? token.slice(0, slashIndex) : token;
|
let prePath = slashIndex != -1 ? token.slice(0, slashIndex) : token;
|
||||||
if (!this.looksLikeOrigin(prePath, { ignoreWhitelist: true })) {
|
if (!this.looksLikeOrigin(prePath, { ignoreKnownDomains: true })) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ var UrlbarTokenizer = {
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Services.uriFixup.isDomainWhitelisted(hostPort)) {
|
if (Services.uriFixup.isDomainKnown(hostPort)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -157,15 +157,15 @@ var UrlbarTokenizer = {
|
||||||
*
|
*
|
||||||
* @param {string} token
|
* @param {string} token
|
||||||
* The string token to verify
|
* The string token to verify
|
||||||
* @param {boolean} [ignoreWhitelist] If true, the origin doesn't have to be
|
* @param {boolean} [ignoreKnownDomains] If true, the origin doesn't have to be
|
||||||
* in the whitelist
|
* in the known domain list
|
||||||
* @param {boolean} [noIp] If true, the origin cannot be an IP address
|
* @param {boolean} [noIp] If true, the origin cannot be an IP address
|
||||||
* @param {boolean} [noPort] If true, the origin cannot have a port number
|
* @param {boolean} [noPort] If true, the origin cannot have a port number
|
||||||
* @returns {boolean} whether the token looks like an origin.
|
* @returns {boolean} whether the token looks like an origin.
|
||||||
*/
|
*/
|
||||||
looksLikeOrigin(
|
looksLikeOrigin(
|
||||||
token,
|
token,
|
||||||
{ ignoreWhitelist = false, noIp = false, noPort = false } = {}
|
{ ignoreKnownDomains = false, noIp = false, noPort = false } = {}
|
||||||
) {
|
) {
|
||||||
if (!token.length) {
|
if (!token.length) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -202,14 +202,14 @@ var UrlbarTokenizer = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it looks like a single word host, check the whitelist.
|
// If it looks like a single word host, check the known domains.
|
||||||
if (
|
if (
|
||||||
!ignoreWhitelist &&
|
!ignoreKnownDomains &&
|
||||||
!userinfo &&
|
!userinfo &&
|
||||||
!hasPort &&
|
!hasPort &&
|
||||||
this.REGEXP_SINGLE_WORD_HOST.test(hostPort)
|
this.REGEXP_SINGLE_WORD_HOST.test(hostPort)
|
||||||
) {
|
) {
|
||||||
return Services.uriFixup.isDomainWhitelisted(hostPort);
|
return Services.uriFixup.isDomainKnown(hostPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -161,8 +161,8 @@ XPCOMUtils.defineLazyGetter(
|
||||||
/^(?:[a-z+.-]+:\/*(?!\/))?\[(?:[0-9a-f]{0,4}:){0,7}[0-9a-f]{0,4}\]?(?::\d+|\/)?/i
|
/^(?:[a-z+.-]+:\/*(?!\/))?\[(?:[0-9a-f]{0,4}:){0,7}[0-9a-f]{0,4}\]?(?::\d+|\/)?/i
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cache of whitelisted domains.
|
// Cache of known domains.
|
||||||
XPCOMUtils.defineLazyGetter(this, "domainsWhitelist", () => {
|
XPCOMUtils.defineLazyGetter(this, "knownDomains", () => {
|
||||||
const branch = "browser.fixup.domainwhitelist.";
|
const branch = "browser.fixup.domainwhitelist.";
|
||||||
let domains = new Set(
|
let domains = new Set(
|
||||||
Services.prefs
|
Services.prefs
|
||||||
|
@ -189,8 +189,8 @@ XPCOMUtils.defineLazyGetter(this, "domainsWhitelist", () => {
|
||||||
return domains;
|
return domains;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cache of whitelisted suffixes.
|
// Cache of known suffixes.
|
||||||
// This works differently from the domains whitelist, because when we examine a
|
// This works differently from the known domains, because when we examine a
|
||||||
// domain we can't tell how many dot-separated parts constitute the suffix.
|
// domain we can't tell how many dot-separated parts constitute the suffix.
|
||||||
// We create a Map keyed by the last dotted part, containing a Set of
|
// We create a Map keyed by the last dotted part, containing a Set of
|
||||||
// all the suffixes ending with that part:
|
// all the suffixes ending with that part:
|
||||||
|
@ -199,7 +199,7 @@ XPCOMUtils.defineLazyGetter(this, "domainsWhitelist", () => {
|
||||||
// When searching we can restrict the linear scan based on the last part.
|
// When searching we can restrict the linear scan based on the last part.
|
||||||
// The ideal structure for this would be a Directed Acyclic Word Graph, but
|
// The ideal structure for this would be a Directed Acyclic Word Graph, but
|
||||||
// since we expect this list to be small it's not worth the complication.
|
// since we expect this list to be small it's not worth the complication.
|
||||||
XPCOMUtils.defineLazyGetter(this, "suffixesWhitelist", () => {
|
XPCOMUtils.defineLazyGetter(this, "knownSuffixes", () => {
|
||||||
const branch = "browser.fixup.domainsuffixwhitelist.";
|
const branch = "browser.fixup.domainsuffixwhitelist.";
|
||||||
let suffixes = new Map();
|
let suffixes = new Map();
|
||||||
let prefs = Services.prefs
|
let prefs = Services.prefs
|
||||||
|
@ -552,7 +552,7 @@ URIFixup.prototype = {
|
||||||
return info;
|
return info;
|
||||||
},
|
},
|
||||||
|
|
||||||
isDomainWhitelisted,
|
isDomainKnown,
|
||||||
|
|
||||||
classID: Components.ID("{c6cf88b7-452e-47eb-bdc9-86e3561648ef}"),
|
classID: Components.ID("{c6cf88b7-452e-47eb-bdc9-86e3561648ef}"),
|
||||||
_xpcom_factory: XPCOMUtils.generateSingletonFactory(URIFixup),
|
_xpcom_factory: XPCOMUtils.generateSingletonFactory(URIFixup),
|
||||||
|
@ -627,16 +627,16 @@ URIFixupInfo.prototype = {
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of isDomainWhitelisted, so we don't have to go through the
|
* Implementation of isDomainKnown, so we don't have to go through the
|
||||||
* service.
|
* service.
|
||||||
* @param {string} asciiHost
|
* @param {string} asciiHost
|
||||||
* @returns {boolean} whether the domain is whitelisted
|
* @returns {boolean} whether the domain is known
|
||||||
*/
|
*/
|
||||||
function isDomainWhitelisted(asciiHost) {
|
function isDomainKnown(asciiHost) {
|
||||||
if (dnsFirstForSingleWords) {
|
if (dnsFirstForSingleWords) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check if this domain is whitelisted as an actual
|
// Check if this domain is known as an actual
|
||||||
// domain (which will prevent a keyword query)
|
// domain (which will prevent a keyword query)
|
||||||
// Note that any processing of the host here should stay in sync with
|
// Note that any processing of the host here should stay in sync with
|
||||||
// code in the front-end(s) that set the pref.
|
// code in the front-end(s) that set the pref.
|
||||||
|
@ -645,19 +645,19 @@ function isDomainWhitelisted(asciiHost) {
|
||||||
asciiHost = asciiHost.substring(0, asciiHost.length - 1);
|
asciiHost = asciiHost.substring(0, asciiHost.length - 1);
|
||||||
lastDotIndex = asciiHost.lastIndexOf(".");
|
lastDotIndex = asciiHost.lastIndexOf(".");
|
||||||
}
|
}
|
||||||
if (domainsWhitelist.has(asciiHost.toLowerCase())) {
|
if (knownDomains.has(asciiHost.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// If there's no dot or only a leading dot we are done, otherwise we'll check
|
// If there's no dot or only a leading dot we are done, otherwise we'll check
|
||||||
// against the suffixes whitelist.
|
// against the known suffixes.
|
||||||
if (lastDotIndex <= 0) {
|
if (lastDotIndex <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Don't use getPublicSuffix here, since the suffix is not in a known list,
|
// Don't use getPublicSuffix here, since the suffix is not in the PSL,
|
||||||
// thus it couldn't tell if the suffix is made up of one or multiple
|
// thus it couldn't tell if the suffix is made up of one or multiple
|
||||||
// dot-separated parts.
|
// dot-separated parts.
|
||||||
let lastPart = asciiHost.substr(lastDotIndex + 1);
|
let lastPart = asciiHost.substr(lastDotIndex + 1);
|
||||||
let suffixes = suffixesWhitelist.get(lastPart);
|
let suffixes = knownSuffixes.get(lastPart);
|
||||||
if (suffixes) {
|
if (suffixes) {
|
||||||
return Array.from(suffixes).some(s => asciiHost.endsWith(s));
|
return Array.from(suffixes).some(s => asciiHost.endsWith(s));
|
||||||
}
|
}
|
||||||
|
@ -672,7 +672,7 @@ function isDomainWhitelisted(asciiHost) {
|
||||||
* @returns {object} result The lookup result.
|
* @returns {object} result The lookup result.
|
||||||
* @returns {string} result.suffix The public suffix if one can be identified.
|
* @returns {string} result.suffix The public suffix if one can be identified.
|
||||||
* @returns {boolean} result.hasUnknownSuffix True when the suffix is not in the
|
* @returns {boolean} result.hasUnknownSuffix True when the suffix is not in the
|
||||||
* Public Suffix List and it's not whitelisted. False in the other cases.
|
* Public Suffix List and it's not in knownSuffixes. False in the other cases.
|
||||||
*/
|
*/
|
||||||
function checkAndFixPublicSuffix(info) {
|
function checkAndFixPublicSuffix(info) {
|
||||||
let uri = info.fixedURI;
|
let uri = info.fixedURI;
|
||||||
|
@ -681,7 +681,7 @@ function checkAndFixPublicSuffix(info) {
|
||||||
!asciiHost ||
|
!asciiHost ||
|
||||||
!asciiHost.includes(".") ||
|
!asciiHost.includes(".") ||
|
||||||
asciiHost.endsWith(".") ||
|
asciiHost.endsWith(".") ||
|
||||||
isDomainWhitelisted(asciiHost)
|
isDomainKnown(asciiHost)
|
||||||
) {
|
) {
|
||||||
return { suffix: "", hasUnknownSuffix: false };
|
return { suffix: "", hasUnknownSuffix: false };
|
||||||
}
|
}
|
||||||
|
@ -918,12 +918,12 @@ function keywordURIFixup(uriString, fixupInfo, isPrivateContext, postData) {
|
||||||
// "docshell site:mozilla.org" - has a space in the origin part
|
// "docshell site:mozilla.org" - has a space in the origin part
|
||||||
// "?site:mozilla.org - anything that begins with a question mark
|
// "?site:mozilla.org - anything that begins with a question mark
|
||||||
// "mozilla'.org" - Things that have a quote before the first dot/colon
|
// "mozilla'.org" - Things that have a quote before the first dot/colon
|
||||||
// "mozilla/test" - non whiteliste host
|
// "mozilla/test" - unknown host
|
||||||
// ".mozilla", "mozilla." - starts or ends with a dot ()
|
// ".mozilla", "mozilla." - starts or ends with a dot ()
|
||||||
|
|
||||||
// These other strings should not be searched, because they could be URIs:
|
// These other strings should not be searched, because they could be URIs:
|
||||||
// "www.blah.com" - Domain with a known or whitelisted suffix
|
// "www.blah.com" - Domain with a standard or known suffix
|
||||||
// "whitelisted" - Whitelisted domain
|
// "knowndomain" - known domain
|
||||||
// "nonQualifiedHost:8888?something" - has a port
|
// "nonQualifiedHost:8888?something" - has a port
|
||||||
// "user@nonQualifiedHost"
|
// "user@nonQualifiedHost"
|
||||||
// "blah.com."
|
// "blah.com."
|
||||||
|
@ -943,14 +943,14 @@ function keywordURIFixup(uriString, fixupInfo, isPrivateContext, postData) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid lookup if we can identify a host and it's whitelisted, or ends with
|
// Avoid lookup if we can identify a host and it's known, or ends with
|
||||||
// a dot and has some path.
|
// a dot and has some path.
|
||||||
// Note that if dnsFirstForSingleWords is true isDomainWhitelisted will always
|
// Note that if dnsFirstForSingleWords is true isDomainKnown will always
|
||||||
// return true, so we can avoid checking dnsFirstForSingleWords after this.
|
// return true, so we can avoid checking dnsFirstForSingleWords after this.
|
||||||
let asciiHost = fixupInfo.fixedURI?.asciiHost;
|
let asciiHost = fixupInfo.fixedURI?.asciiHost;
|
||||||
if (
|
if (
|
||||||
asciiHost &&
|
asciiHost &&
|
||||||
(isDomainWhitelisted(asciiHost) ||
|
(isDomainKnown(asciiHost) ||
|
||||||
(asciiHost.endsWith(".") &&
|
(asciiHost.endsWith(".") &&
|
||||||
asciiHost.indexOf(".") != asciiHost.length - 1))
|
asciiHost.indexOf(".") != asciiHost.length - 1))
|
||||||
) {
|
) {
|
||||||
|
@ -997,7 +997,7 @@ function keywordURIFixupLegacy(
|
||||||
// "?mozilla" - anything that begins with a question mark
|
// "?mozilla" - anything that begins with a question mark
|
||||||
// "?site:mozilla.org docshell"
|
// "?site:mozilla.org docshell"
|
||||||
// Things that have a quote before the first dot/colon
|
// Things that have a quote before the first dot/colon
|
||||||
// "mozilla" - checked against a whitelist to see if it's a host or not
|
// "mozilla" - checked against the knownDomains to see if it's a host or not
|
||||||
// ".mozilla", "mozilla." - ditto
|
// ".mozilla", "mozilla." - ditto
|
||||||
|
|
||||||
// These are not keyword formatted strings
|
// These are not keyword formatted strings
|
||||||
|
@ -1027,11 +1027,11 @@ function keywordURIFixupLegacy(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid lookup if we can identify a host and it's whitelisted.
|
// Avoid lookup if we can identify a host and it's known.
|
||||||
// Note that if dnsFirstForSingleWords is true isDomainWhitelisted will always
|
// Note that if dnsFirstForSingleWords is true isDomainKnown will always
|
||||||
// return true, so we can avoid checking dnsFirstForSingleWords after this.
|
// return true, so we can avoid checking dnsFirstForSingleWords after this.
|
||||||
let asciiHost = fixupInfo.fixedURI?.asciiHost;
|
let asciiHost = fixupInfo.fixedURI?.asciiHost;
|
||||||
if (asciiHost && isDomainWhitelisted(asciiHost)) {
|
if (asciiHost && isDomainKnown(asciiHost)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,13 +158,13 @@ interface nsIURIFixup : nsISupports
|
||||||
[optional] out nsIInputStream aPostData);
|
[optional] out nsIInputStream aPostData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the specified domain is whitelisted and false otherwise.
|
* Returns true if the specified domain is known and false otherwise.
|
||||||
* A whitelisted domain is relevant when we have a single word and can't be
|
* A known domain is relevant when we have a single word and can't be
|
||||||
* sure whether to treat the word as a host name or should instead be
|
* sure whether to treat the word as a host name or should instead be
|
||||||
* treated as a search term.
|
* treated as a search term.
|
||||||
*
|
*
|
||||||
* @param aDomain A domain name to query.
|
* @param aDomain A domain name to query.
|
||||||
*/
|
*/
|
||||||
bool isDomainWhitelisted(in AUTF8String aDomain);
|
bool isDomainKnown(in AUTF8String aDomain);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче