diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 06:50:41 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 06:50:41 +0000 |
commit | 8fc500d1b5d8b5bfddf829132606f91df1a841e6 (patch) | |
tree | 8f4567d80363afbdd26bfd5e6b0590822d789120 /chrome/common/extensions/url_pattern.cc | |
parent | 9320f85bc4fcdb342288821697d0e988d4d670ed (diff) | |
download | chromium_src-8fc500d1b5d8b5bfddf829132606f91df1a841e6.zip chromium_src-8fc500d1b5d8b5bfddf829132606f91df1a841e6.tar.gz chromium_src-8fc500d1b5d8b5bfddf829132606f91df1a841e6.tar.bz2 |
When a content script has a match pattern of http://*/*, we
should run on web pages that have an IP address for their
host.
BUG=18256
TEST=Added unit test
Review URL: http://codereview.chromium.org/159767
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22260 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/url_pattern.cc')
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index 7a4f853..b3a5e80 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -94,16 +94,24 @@ bool URLPattern::MatchesUrl(const GURL &test) const { } bool URLPattern::MatchesHost(const GURL& test) const { + // If the hosts are exactly equal, we have a match. if (test.host() == host_) return true; - if (!match_subdomains_ || test.HostIsIPAddress()) + // If we're matching subdomains, and we have no host in the match pattern, + // that means that we're matching all hosts, which means we have a match no + // matter what the test host is. + if (match_subdomains_ && host_.empty()) + return true; + + // Otherwise, we can only match if our match pattern matches subdomains. + if (!match_subdomains_) return false; - // If we're matching subdomains, and we have no host, that means the pattern - // was <scheme>://*/<whatever>, so we match anything. - if (host_.empty()) - return true; + // We don't do subdomain matching against IP addresses, so we can give up now + // if the test host is an IP address. + if (test.HostIsIPAddress()) + return false; // Check if the test host is a subdomain of our host. if (test.host().length() <= (host_.length() + 1)) |