Changeset 57990 in webkit
- Timestamp:
- Apr 21, 2010 9:40:03 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r57987 r57990 1 2010-04-21 Timothy Hatcher <timothy@apple.com> 2 3 Make UserContentURLPattern correctly check for subdomains and the URL 4 has the same suffix as the pattern. Also improve the parsing of the host. 5 6 https://bugs.webkit.org/show_bug.cgi?id=37357 7 8 Reviewed by Darin Adler. 9 10 * page/UserContentURLPattern.cpp: 11 (WebCore::UserContentURLPattern::parse): Simplify the subdomain pattern parsing to 12 simply check for "*" only or a "*." prefix and then do a substring. 13 (WebCore::UserContentURLPattern::matchesHost): Check that the host has a "." in the 14 position before the suffix to ensure it a subdomain and not just a suffix match. 15 1 16 2010-04-21 Xan Lopez <xlopez@igalia.com> 2 17 -
trunk/WebCore/page/UserContentURLPattern.cpp
r57923 r57990 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 82 82 if (hostEndPos == -1) 83 83 return false; 84 84 85 85 m_host = pattern.substring(hostStartPos, hostEndPos - hostStartPos); 86 87 // The first component can be '*', which means to match all subdomains. 88 Vector<String> hostComponents;89 m_host.split(".", hostComponents);90 if (hostComponents[0] == "*") {86 m_matchSubdomains = false; 87 88 if (m_host == "*") { 89 // The pattern can be just '*', which means match all domains. 90 m_host = ""; 91 91 m_matchSubdomains = true; 92 m_host = ""; 93 for (unsigned i = 1; i < hostComponents.size(); ++i) { 94 m_host = m_host + hostComponents[i]; 95 if (i < hostComponents.size() - 1) 96 m_host = m_host + "."; 97 } 98 } 99 92 } else if (m_host.startsWith("*.")) { 93 // The first component can be '*', which means to match all subdomains. 94 m_host = m_host.substring(2); // Length of "*." 95 m_matchSubdomains = true; 96 } 97 100 98 // No other '*' can occur in the host. 101 99 if (m_host.find("*") != -1) … … 126 124 bool UserContentURLPattern::matchesHost(const KURL& test) const 127 125 { 128 if (equalIgnoringCase(test.host(), m_host)) 126 const String& host = test.host(); 127 if (equalIgnoringCase(host, m_host)) 129 128 return true; 130 129 … … 137 136 return true; 138 137 139 // Check if the test host is a subdomain of our host. 140 return test.host().endsWith(m_host, false); 138 // Check if the domain is a subdomain of our host. 139 if (!host.endsWith(m_host, false)) 140 return false; 141 142 ASSERT(host.length() > m_host.length()); 143 144 // Check that the character before the suffix is a period. 145 return host[host.length() - m_host.length() - 1] == '.'; 141 146 } 142 147
Note: See TracChangeset
for help on using the changeset viewer.