зеркало из 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);
|
||||
// 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
|
||||
// Services.uriFixup.isDomainWhitelisted() instead.
|
||||
// Services.uriFixup.isDomainKnown() instead.
|
||||
pref("browser.fixup.domainwhitelist.localhost", true);
|
||||
// https://tools.ietf.org/html/rfc2606
|
||||
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
|
||||
// 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
|
||||
// search here, bypassing the docShell, we need invoke the same check
|
||||
// ourselves. See also URIFixupChild.jsm and keyword-uri-fixup.
|
||||
|
@ -842,8 +842,8 @@ class UrlbarInput {
|
|||
let { value, selectionStart, selectionEnd } = result.autofill;
|
||||
this._autofillValue(value, selectionStart, selectionEnd);
|
||||
} else {
|
||||
// If the url is trimmed but it's invalid (for example it has a non
|
||||
// whitelisted single word host, or an unknown domain suffix), trimming
|
||||
// If the url is trimmed but it's invalid (for example it has an unknown
|
||||
// single word host, or an unknown domain suffix), trimming
|
||||
// it would end up executing a search instead of visiting it.
|
||||
let allowTrim = true;
|
||||
if (
|
||||
|
|
|
@ -104,7 +104,7 @@ var UrlbarTokenizer = {
|
|||
// having a protocol.
|
||||
let slashIndex = token.indexOf("/");
|
||||
let prePath = slashIndex != -1 ? token.slice(0, slashIndex) : token;
|
||||
if (!this.looksLikeOrigin(prePath, { ignoreWhitelist: true })) {
|
||||
if (!this.looksLikeOrigin(prePath, { ignoreKnownDomains: true })) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ var UrlbarTokenizer = {
|
|||
) {
|
||||
return true;
|
||||
}
|
||||
if (Services.uriFixup.isDomainWhitelisted(hostPort)) {
|
||||
if (Services.uriFixup.isDomainKnown(hostPort)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -157,15 +157,15 @@ var UrlbarTokenizer = {
|
|||
*
|
||||
* @param {string} token
|
||||
* The string token to verify
|
||||
* @param {boolean} [ignoreWhitelist] If true, the origin doesn't have to be
|
||||
* in the whitelist
|
||||
* @param {boolean} [ignoreKnownDomains] If true, the origin doesn't have to be
|
||||
* in the known domain list
|
||||
* @param {boolean} [noIp] If true, the origin cannot be an IP address
|
||||
* @param {boolean} [noPort] If true, the origin cannot have a port number
|
||||
* @returns {boolean} whether the token looks like an origin.
|
||||
*/
|
||||
looksLikeOrigin(
|
||||
token,
|
||||
{ ignoreWhitelist = false, noIp = false, noPort = false } = {}
|
||||
{ ignoreKnownDomains = false, noIp = false, noPort = false } = {}
|
||||
) {
|
||||
if (!token.length) {
|
||||
return false;
|
||||
|
@ -202,14 +202,14 @@ var UrlbarTokenizer = {
|
|||
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 (
|
||||
!ignoreWhitelist &&
|
||||
!ignoreKnownDomains &&
|
||||
!userinfo &&
|
||||
!hasPort &&
|
||||
this.REGEXP_SINGLE_WORD_HOST.test(hostPort)
|
||||
) {
|
||||
return Services.uriFixup.isDomainWhitelisted(hostPort);
|
||||
return Services.uriFixup.isDomainKnown(hostPort);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -161,8 +161,8 @@ XPCOMUtils.defineLazyGetter(
|
|||
/^(?:[a-z+.-]+:\/*(?!\/))?\[(?:[0-9a-f]{0,4}:){0,7}[0-9a-f]{0,4}\]?(?::\d+|\/)?/i
|
||||
);
|
||||
|
||||
// Cache of whitelisted domains.
|
||||
XPCOMUtils.defineLazyGetter(this, "domainsWhitelist", () => {
|
||||
// Cache of known domains.
|
||||
XPCOMUtils.defineLazyGetter(this, "knownDomains", () => {
|
||||
const branch = "browser.fixup.domainwhitelist.";
|
||||
let domains = new Set(
|
||||
Services.prefs
|
||||
|
@ -189,8 +189,8 @@ XPCOMUtils.defineLazyGetter(this, "domainsWhitelist", () => {
|
|||
return domains;
|
||||
});
|
||||
|
||||
// Cache of whitelisted suffixes.
|
||||
// This works differently from the domains whitelist, because when we examine a
|
||||
// Cache of known suffixes.
|
||||
// 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.
|
||||
// We create a Map keyed by the last dotted part, containing a Set of
|
||||
// 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.
|
||||
// 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.
|
||||
XPCOMUtils.defineLazyGetter(this, "suffixesWhitelist", () => {
|
||||
XPCOMUtils.defineLazyGetter(this, "knownSuffixes", () => {
|
||||
const branch = "browser.fixup.domainsuffixwhitelist.";
|
||||
let suffixes = new Map();
|
||||
let prefs = Services.prefs
|
||||
|
@ -552,7 +552,7 @@ URIFixup.prototype = {
|
|||
return info;
|
||||
},
|
||||
|
||||
isDomainWhitelisted,
|
||||
isDomainKnown,
|
||||
|
||||
classID: Components.ID("{c6cf88b7-452e-47eb-bdc9-86e3561648ef}"),
|
||||
_xpcom_factory: XPCOMUtils.generateSingletonFactory(URIFixup),
|
||||
|
@ -627,16 +627,16 @@ URIFixupInfo.prototype = {
|
|||
// 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.
|
||||
* @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) {
|
||||
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)
|
||||
// Note that any processing of the host here should stay in sync with
|
||||
// code in the front-end(s) that set the pref.
|
||||
|
@ -645,19 +645,19 @@ function isDomainWhitelisted(asciiHost) {
|
|||
asciiHost = asciiHost.substring(0, asciiHost.length - 1);
|
||||
lastDotIndex = asciiHost.lastIndexOf(".");
|
||||
}
|
||||
if (domainsWhitelist.has(asciiHost.toLowerCase())) {
|
||||
if (knownDomains.has(asciiHost.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
// 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) {
|
||||
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
|
||||
// dot-separated parts.
|
||||
let lastPart = asciiHost.substr(lastDotIndex + 1);
|
||||
let suffixes = suffixesWhitelist.get(lastPart);
|
||||
let suffixes = knownSuffixes.get(lastPart);
|
||||
if (suffixes) {
|
||||
return Array.from(suffixes).some(s => asciiHost.endsWith(s));
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ function isDomainWhitelisted(asciiHost) {
|
|||
* @returns {object} result The lookup result.
|
||||
* @returns {string} result.suffix The public suffix if one can be identified.
|
||||
* @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) {
|
||||
let uri = info.fixedURI;
|
||||
|
@ -681,7 +681,7 @@ function checkAndFixPublicSuffix(info) {
|
|||
!asciiHost ||
|
||||
!asciiHost.includes(".") ||
|
||||
asciiHost.endsWith(".") ||
|
||||
isDomainWhitelisted(asciiHost)
|
||||
isDomainKnown(asciiHost)
|
||||
) {
|
||||
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
|
||||
// "?site:mozilla.org - anything that begins with a question mark
|
||||
// "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 ()
|
||||
|
||||
// These other strings should not be searched, because they could be URIs:
|
||||
// "www.blah.com" - Domain with a known or whitelisted suffix
|
||||
// "whitelisted" - Whitelisted domain
|
||||
// "www.blah.com" - Domain with a standard or known suffix
|
||||
// "knowndomain" - known domain
|
||||
// "nonQualifiedHost:8888?something" - has a port
|
||||
// "user@nonQualifiedHost"
|
||||
// "blah.com."
|
||||
|
@ -943,14 +943,14 @@ function keywordURIFixup(uriString, fixupInfo, isPrivateContext, postData) {
|
|||
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.
|
||||
// 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.
|
||||
let asciiHost = fixupInfo.fixedURI?.asciiHost;
|
||||
if (
|
||||
asciiHost &&
|
||||
(isDomainWhitelisted(asciiHost) ||
|
||||
(isDomainKnown(asciiHost) ||
|
||||
(asciiHost.endsWith(".") &&
|
||||
asciiHost.indexOf(".") != asciiHost.length - 1))
|
||||
) {
|
||||
|
@ -997,7 +997,7 @@ function keywordURIFixupLegacy(
|
|||
// "?mozilla" - anything that begins with a question mark
|
||||
// "?site:mozilla.org docshell"
|
||||
// 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
|
||||
|
||||
// These are not keyword formatted strings
|
||||
|
@ -1027,11 +1027,11 @@ function keywordURIFixupLegacy(
|
|||
);
|
||||
}
|
||||
|
||||
// Avoid lookup if we can identify a host and it's whitelisted.
|
||||
// Note that if dnsFirstForSingleWords is true isDomainWhitelisted will always
|
||||
// Avoid lookup if we can identify a host and it's known.
|
||||
// Note that if dnsFirstForSingleWords is true isDomainKnown will always
|
||||
// return true, so we can avoid checking dnsFirstForSingleWords after this.
|
||||
let asciiHost = fixupInfo.fixedURI?.asciiHost;
|
||||
if (asciiHost && isDomainWhitelisted(asciiHost)) {
|
||||
if (asciiHost && isDomainKnown(asciiHost)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,13 +158,13 @@ interface nsIURIFixup : nsISupports
|
|||
[optional] out nsIInputStream aPostData);
|
||||
|
||||
/**
|
||||
* Returns true if the specified domain is whitelisted and false otherwise.
|
||||
* A whitelisted domain is relevant when we have a single word and can't be
|
||||
* Returns true if the specified domain is known and false otherwise.
|
||||
* 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
|
||||
* treated as a search term.
|
||||
*
|
||||
* @param aDomain A domain name to query.
|
||||
*/
|
||||
bool isDomainWhitelisted(in AUTF8String aDomain);
|
||||
bool isDomainKnown(in AUTF8String aDomain);
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче