| Index: extensions/common/manifest_handlers/externally_connectable.cc
|
| diff --git a/extensions/common/manifest_handlers/externally_connectable.cc b/extensions/common/manifest_handlers/externally_connectable.cc
|
| index e594251454d53afe6ed13777e0047345bd7d2b11..7dcdaffcb546269e0230463cbde36ba8b0b18f70 100644
|
| --- a/extensions/common/manifest_handlers/externally_connectable.cc
|
| +++ b/extensions/common/manifest_handlers/externally_connectable.cc
|
| @@ -20,7 +20,6 @@
|
| #include "extensions/common/permissions/api_permission_set.h"
|
| #include "extensions/common/url_pattern.h"
|
| #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
| -#include "net/base/url_util.h"
|
| #include "url/gurl.h"
|
|
|
| namespace rcd = net::registry_controlled_domains;
|
| @@ -140,20 +139,9 @@
|
| continue;
|
| }
|
|
|
| - url::CanonHostInfo host_info;
|
| - std::string canonical_host =
|
| - net::CanonicalizeHost(pattern.host(), &host_info);
|
| - if (canonical_host.empty()) {
|
| - // CanonicalizeHost returns empty string on error. The URL parsing
|
| - // combined with host().empty() should have caught this above.
|
| - *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - errors::kErrorInvalidMatchPattern, *it);
|
| - return std::unique_ptr<ExternallyConnectableInfo>();
|
| - }
|
| -
|
| // Wildcards on subdomains of a TLD are not allowed.
|
| - bool has_registry = rcd::HostHasRegistryControlledDomain(
|
| - canonical_host,
|
| + size_t registry_length = rcd::GetRegistryLength(
|
| + pattern.host(),
|
| // This means that things that look like TLDs - the foobar in
|
| // http://google.foobar - count as TLDs.
|
| rcd::INCLUDE_UNKNOWN_REGISTRIES,
|
| @@ -161,9 +149,17 @@
|
| // codereview.appspot.com and evil.appspot.com are different.
|
| rcd::INCLUDE_PRIVATE_REGISTRIES);
|
|
|
| + if (registry_length == std::string::npos) {
|
| + // The URL parsing combined with host().empty() should have caught this.
|
| + NOTREACHED() << *it;
|
| + *error = ErrorUtils::FormatErrorMessageUTF16(
|
| + errors::kErrorInvalidMatchPattern, *it);
|
| + return std::unique_ptr<ExternallyConnectableInfo>();
|
| + }
|
| +
|
| // Broad match patterns like "*.com", "*.co.uk", and even "*.appspot.com"
|
| // are not allowed. However just "appspot.com" is ok.
|
| - if (!has_registry && pattern.match_subdomains()) {
|
| + if (registry_length == 0 && pattern.match_subdomains()) {
|
| // Warning not error for forwards compatibility.
|
| install_warnings->push_back(
|
| InstallWarning(ErrorUtils::FormatErrorMessage(
|
|
|