Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: chrome/common/extensions/url_pattern.cc

Issue 165366: Merge 22260 - When a content script has a match pattern of http://*/*, we... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/url_pattern_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/url_pattern.cc
===================================================================
--- chrome/common/extensions/url_pattern.cc (revision 23142)
+++ chrome/common/extensions/url_pattern.cc (working copy)
@@ -94,16 +94,24 @@
}
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))
Property changes on: chrome\common\extensions\url_pattern.cc
___________________________________________________________________
Added: svn:mergeinfo
Merged /trunk/src/chrome/common/extensions/url_pattern.cc:r22260
Merged /branches/chrome_webkit_merge_branch/chrome/common/extensions/url_pattern.cc:r69-2775
« no previous file with comments | « no previous file | chrome/common/extensions/url_pattern_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698