diff options
author | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-23 01:57:48 +0000 |
---|---|---|
committer | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-23 01:57:48 +0000 |
commit | 5b71f1d4ffa6e2f9c6e87254f5ea825f0a49fa53 (patch) | |
tree | 1d9c40beca66e2977c59cd496c6e5f038b303d46 /extensions/common | |
parent | b102bbd622753faeb7440d59174fdedfb70c54da (diff) | |
download | chromium_src-5b71f1d4ffa6e2f9c6e87254f5ea825f0a49fa53.zip chromium_src-5b71f1d4ffa6e2f9c6e87254f5ea825f0a49fa53.tar.gz chromium_src-5b71f1d4ffa6e2f9c6e87254f5ea825f0a49fa53.tar.bz2 |
Ignoring missing backslash at the end of a path if not specified by the url, but by the pattern
BUG=171814
TEST=unittest
Review URL: https://chromiumcodereview.appspot.com/12321051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/url_pattern.cc | 8 | ||||
-rw-r--r-- | extensions/common/url_pattern_unittest.cc | 20 |
2 files changed, 25 insertions, 3 deletions
diff --git a/extensions/common/url_pattern.cc b/extensions/common/url_pattern.cc index 1fea36a..820aacf 100644 --- a/extensions/common/url_pattern.cc +++ b/extensions/common/url_pattern.cc @@ -399,10 +399,12 @@ bool URLPattern::MatchesHost(const GURL& test) const { } bool URLPattern::MatchesPath(const std::string& test) const { - if (!MatchPattern(test, path_escaped_)) - return false; + // Make the behaviour of OverlapsWith consistent with MatchesURL, which is + // need to match hosted apps on e.g. 'google.com' also run on 'google.com/'. + if (test + "/*" == path_escaped_) + return true; - return true; + return MatchPattern(test, path_escaped_); } const std::string& URLPattern::GetAsString() const { diff --git a/extensions/common/url_pattern_unittest.cc b/extensions/common/url_pattern_unittest.cc index be8a9c0..9d12163 100644 --- a/extensions/common/url_pattern_unittest.cc +++ b/extensions/common/url_pattern_unittest.cc @@ -553,6 +553,26 @@ TEST(ExtensionURLPatternTest, IgnorePorts) { EXPECT_FALSE(pattern.MatchesURL(url)); } +TEST(ExtensionURLPatternTest, IgnoreMissingBackslashes) { + std::string pattern_str1 = "http://www.example.com/example"; + std::string pattern_str2 = "http://www.example.com/example/*"; + GURL url1("http://www.example.com/example"); + GURL url2("http://www.example.com/example/"); + + URLPattern pattern1(kAllSchemes); + EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern1.Parse(pattern_str1)); + URLPattern pattern2(kAllSchemes); + EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern2.Parse(pattern_str2)); + + // Same patterns should match same urls. + EXPECT_TRUE(pattern1.MatchesURL(url1)); + EXPECT_TRUE(pattern2.MatchesURL(url2)); + // The not terminated path should match the terminated pattern. + EXPECT_TRUE(pattern2.MatchesURL(url1)); + // The terminated path however should not match the unterminated pattern. + EXPECT_FALSE(pattern1.MatchesURL(url2)); +} + TEST(ExtensionURLPatternTest, Equals) { const struct { const char* pattern1; |