diff options
author | Steve Block <steveblock@google.com> | 2010-04-27 16:31:00 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-11 14:42:12 +0100 |
commit | dcc8cf2e65d1aa555cce12431a16547e66b469ee (patch) | |
tree | 92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/page/UserContentURLPattern.cpp | |
parent | ccac38a6b48843126402088a309597e682f40fe6 (diff) | |
download | external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2 |
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/page/UserContentURLPattern.cpp')
-rw-r--r-- | WebCore/page/UserContentURLPattern.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/WebCore/page/UserContentURLPattern.cpp b/WebCore/page/UserContentURLPattern.cpp index 5f0a311..09eb678 100644 --- a/WebCore/page/UserContentURLPattern.cpp +++ b/WebCore/page/UserContentURLPattern.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -75,28 +75,26 @@ bool UserContentURLPattern::parse(const String& pattern) int pathStartPos = 0; - if (m_scheme == "file") + if (equalIgnoringCase(m_scheme, "file")) pathStartPos = hostStartPos; else { int hostEndPos = pattern.find("/", hostStartPos); if (hostEndPos == -1) return false; - + m_host = pattern.substring(hostStartPos, hostEndPos - hostStartPos); + m_matchSubdomains = false; - // The first component can be '*', which means to match all subdomains. - Vector<String> hostComponents; - m_host.split(".", hostComponents); - if (hostComponents[0] == "*") { - m_matchSubdomains = true; + if (m_host == "*") { + // The pattern can be just '*', which means match all domains. m_host = ""; - for (unsigned i = 1; i < hostComponents.size(); ++i) { - m_host = m_host + hostComponents[i]; - if (i < hostComponents.size() - 1) - m_host = m_host + "."; - } + m_matchSubdomains = true; + } else if (m_host.startsWith("*.")) { + // The first component can be '*', which means to match all subdomains. + m_host = m_host.substring(2); // Length of "*." + m_matchSubdomains = true; } - + // No other '*' can occur in the host. if (m_host.find("*") != -1) return false; @@ -114,10 +112,10 @@ bool UserContentURLPattern::matches(const KURL& test) const if (m_invalid) return false; - if (test.protocol() != m_scheme) + if (!equalIgnoringCase(test.protocol(), m_scheme)) return false; - if (!matchesHost(test)) + if (!equalIgnoringCase(m_scheme, "file") && !matchesHost(test)) return false; return matchesPath(test); @@ -125,7 +123,8 @@ bool UserContentURLPattern::matches(const KURL& test) const bool UserContentURLPattern::matchesHost(const KURL& test) const { - if (test.host() == m_host) + const String& host = test.host(); + if (equalIgnoringCase(host, m_host)) return true; if (!m_matchSubdomains) @@ -136,8 +135,14 @@ bool UserContentURLPattern::matchesHost(const KURL& test) const if (!m_host.length()) return true; - // Check if the test host is a subdomain of our host. - return test.host().endsWith(m_host, false); + // Check if the domain is a subdomain of our host. + if (!host.endsWith(m_host, false)) + return false; + + ASSERT(host.length() > m_host.length()); + + // Check that the character before the suffix is a period. + return host[host.length() - m_host.length() - 1] == '.'; } struct MatchTester |