Chromium Code Reviews| Index: Source/platform/weborigin/OriginAccessEntry.cpp |
| diff --git a/Source/platform/weborigin/OriginAccessEntry.cpp b/Source/platform/weborigin/OriginAccessEntry.cpp |
| index 8bcd1b294f2b3426e1febec039416669b9570801..37f9a3fb6354e9163005a33b82699a26a934e49a 100644 |
| --- a/Source/platform/weborigin/OriginAccessEntry.cpp |
| +++ b/Source/platform/weborigin/OriginAccessEntry.cpp |
| @@ -31,12 +31,34 @@ |
| #include "config.h" |
| #include "platform/weborigin/OriginAccessEntry.h" |
| +#include "platform/weborigin/KURL.h" |
| #include "platform/weborigin/SecurityOrigin.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebPublicSuffixList.h" |
| +#include <url/third_party/mozilla/url_parse.h> |
|
Ryan Sleevi
2015/05/13 23:23:34
what the wat?
Mike West
2015/05/15 14:45:16
This is where 'url::Component' is defined. Don't a
|
| +#include <url/url_canon.h> |
| namespace blink { |
| +namespace { |
| + |
| + bool HostIsIPAddress(const String& host) |
|
jochen (gone - plz use gerrit)
2015/05/15 14:44:13
no indent
|
| + { |
| + if (host.isEmpty()) |
| + return false; |
| + |
| + KURL url(KURL(), "http://" + host + "/"); |
| + if (!url.isValid()) |
| + return false; |
| + |
| + url::RawCanonOutputT<char, 128> ignoredOutput; |
| + url::CanonHostInfo hostInfo; |
| + url::Component hostComponent(7, host.length()); |
|
Ryan Sleevi
2015/05/13 23:23:34
grumble-nit - It's not immediately obvious that th
jochen (gone - plz use gerrit)
2015/05/15 14:44:13
why not make it https:// already now :)
Mike West
2015/05/15 14:45:16
I _should_ change this to HTTPS! It'll be tons mor
|
| + url::CanonicalizeIPAddress(url.string().utf8().data(), hostComponent, &ignoredOutput, &hostInfo); |
| + return hostInfo.IsIPAddress(); |
|
Ryan Sleevi
2015/05/13 23:23:34
This is basically duplicating GURL::HostIsIPAddres
Mike West
2015/05/15 14:45:16
Noted.
|
| + } |
| +} |
| + |
| OriginAccessEntry::OriginAccessEntry(const String& protocol, const String& host, SubdomainSetting subdomainSetting, IPAddressSetting ipAddressSetting) |
| : m_protocol(protocol.lower()) |
| , m_host(host.lower()) |
| @@ -46,8 +68,7 @@ OriginAccessEntry::OriginAccessEntry(const String& protocol, const String& host, |
| { |
| ASSERT(subdomainSetting == AllowSubdomains || subdomainSetting == DisallowSubdomains); |
| - // Assume that any host that ends with a digit is trying to be an IP address. |
| - m_hostIsIPAddress = !m_host.isEmpty() && isASCIIDigit(m_host[m_host.length() - 1]); |
| + m_hostIsIPAddress = HostIsIPAddress(host); |
| // Look for top-level domains, either with or without an additional dot. |
| if (!m_hostIsIPAddress) { |