Bug 1643093 - Remove references to 'whitelist' in browser/components/urlbar. r=jaws

Depends on D78124

Differential Revision: https://phabricator.services.mozilla.com/D78122
This commit is contained in:
Jared Wein 2020-06-24 15:59:04 +00:00
Родитель e9fd271cc7
Коммит 7639e4f712
7 изменённых файлов: 46 добавлений и 48 удалений

Просмотреть файл

@ -198,7 +198,7 @@ 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);

Просмотреть файл

@ -679,7 +679,7 @@ class UrlbarInput {
// When fixing a single word to a search, the docShell would also
// query the DNS and if resolved ask the user whether they would
// rather visit that as a host. On a positive answer, it adds the host
// the the list that we use to make decisions.
// to the list that we use to make decisions.
// Because we are directly asking for a search here, bypassing the
// docShell, we need to do the same ourselves.
// See also URIFixupChild.jsm and keyword-uri-fixup.
@ -865,8 +865,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);
};

Просмотреть файл

@ -1344,8 +1344,9 @@ Search.prototype = {
// We may not have auto-filled, but this may still look like a URL.
// However, even if the input is a valid URL, we may not want to use
// it as such. This can happen if the host would require whitelisting,
// but isn't in the whitelist.
// it as such. This can happen if the host isn't using a known TLD
// and hasn't been added to a user-controlled list of known domains,
// and/or if it looks like an email address.
let matched = await this._matchUnknownUrl();
if (matched) {
// Since we can't tell if this is a real URL and whether the user wants
@ -1393,7 +1394,7 @@ Search.prototype = {
let query, params;
if (
UrlbarTokenizer.looksLikeOrigin(this._searchString, {
ignoreWhitelist: true,
ignoreKnownDomains: true,
})
) {
[query, params] = this._originQuery;
@ -1498,7 +1499,7 @@ Search.prototype = {
}
// If the search string looks more like a url than a domain, bail out.
if (
!UrlbarTokenizer.looksLikeOrigin(searchStr, { ignoreWhitelist: true })
!UrlbarTokenizer.looksLikeOrigin(searchStr, { ignoreKnownDomains: true })
) {
return false;
}

Просмотреть файл

@ -83,8 +83,6 @@ avoid-blacklist-and-whitelist:
- browser/components/urlbar/tests/browser/browser_UrlbarInput_trimURLs.js
- browser/components/urlbar/tests/unit/test_search_suggestions.js
- browser/components/urlbar/tests/unit/test_tokenizer.js
- browser/components/urlbar/UrlbarInput.jsm
- browser/components/urlbar/UrlbarTokenizer.jsm
- browser/extensions/formautofill/FormAutofillSync.jsm
- browser/extensions/screenshots/background/main.js
- browser/modules/SitePermissions.jsm
@ -421,7 +419,6 @@ avoid-blacklist-and-whitelist:
- toolkit/components/extensions/test/xpcshell/test_ext_storage_content_sync_kinto.js
- toolkit/components/extensions/test/xpcshell/test_WebExtensionPolicy.js
- toolkit/components/places/tests/unifiedcomplete/test_visit_url.js
- toolkit/components/places/UnifiedComplete.jsm
- toolkit/components/remotepagemanager/RemotePageManagerParent.jsm
- toolkit/components/reputationservice/ApplicationReputation.cpp
- toolkit/components/reputationservice/chromium/chrome/common/safe_browsing/csd.pb.h