| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 return matchesWhitelist && !matchesBlacklist; | 62 return matchesWhitelist && !matchesBlacklist; |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool UserContentURLPattern::parse(const String& pattern) | 65 bool UserContentURLPattern::parse(const String& pattern) |
| 66 { | 66 { |
| 67 DEFINE_STATIC_LOCAL(const String, schemeSeparator, ("://")); | 67 DEFINE_STATIC_LOCAL(const String, schemeSeparator, ("://")); |
| 68 | 68 |
| 69 size_t schemeEndPos = pattern.find(schemeSeparator); | 69 size_t schemeEndPos = pattern.find(schemeSeparator); |
| 70 if (schemeEndPos == notFound) | 70 if (schemeEndPos == kNotFound) |
| 71 return false; | 71 return false; |
| 72 | 72 |
| 73 m_scheme = pattern.left(schemeEndPos); | 73 m_scheme = pattern.left(schemeEndPos); |
| 74 | 74 |
| 75 unsigned hostStartPos = schemeEndPos + schemeSeparator.length(); | 75 unsigned hostStartPos = schemeEndPos + schemeSeparator.length(); |
| 76 if (hostStartPos >= pattern.length()) | 76 if (hostStartPos >= pattern.length()) |
| 77 return false; | 77 return false; |
| 78 | 78 |
| 79 int pathStartPos = 0; | 79 int pathStartPos = 0; |
| 80 | 80 |
| 81 if (equalIgnoringCase(m_scheme, "file")) | 81 if (equalIgnoringCase(m_scheme, "file")) |
| 82 pathStartPos = hostStartPos; | 82 pathStartPos = hostStartPos; |
| 83 else { | 83 else { |
| 84 size_t hostEndPos = pattern.find("/", hostStartPos); | 84 size_t hostEndPos = pattern.find("/", hostStartPos); |
| 85 if (hostEndPos == notFound) | 85 if (hostEndPos == kNotFound) |
| 86 return false; | 86 return false; |
| 87 | 87 |
| 88 m_host = pattern.substring(hostStartPos, hostEndPos - hostStartPos); | 88 m_host = pattern.substring(hostStartPos, hostEndPos - hostStartPos); |
| 89 m_matchSubdomains = false; | 89 m_matchSubdomains = false; |
| 90 | 90 |
| 91 if (m_host == "*") { | 91 if (m_host == "*") { |
| 92 // The pattern can be just '*', which means match all domains. | 92 // The pattern can be just '*', which means match all domains. |
| 93 m_host = ""; | 93 m_host = ""; |
| 94 m_matchSubdomains = true; | 94 m_matchSubdomains = true; |
| 95 } else if (m_host.startsWith("*.")) { | 95 } else if (m_host.startsWith("*.")) { |
| 96 // The first component can be '*', which means to match all subdomai
ns. | 96 // The first component can be '*', which means to match all subdomai
ns. |
| 97 m_host = m_host.substring(2); // Length of "*." | 97 m_host = m_host.substring(2); // Length of "*." |
| 98 m_matchSubdomains = true; | 98 m_matchSubdomains = true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 // No other '*' can occur in the host. | 101 // No other '*' can occur in the host. |
| 102 if (m_host.find("*") != notFound) | 102 if (m_host.find("*") != kNotFound) |
| 103 return false; | 103 return false; |
| 104 | 104 |
| 105 pathStartPos = hostEndPos; | 105 pathStartPos = hostEndPos; |
| 106 } | 106 } |
| 107 | 107 |
| 108 m_path = pattern.right(pattern.length() - pathStartPos); | 108 m_path = pattern.right(pattern.length() - pathStartPos); |
| 109 | 109 |
| 110 return true; | 110 return true; |
| 111 } | 111 } |
| 112 | 112 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 225 } |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 bool UserContentURLPattern::matchesPath(const KURL& test) const | 228 bool UserContentURLPattern::matchesPath(const KURL& test) const |
| 229 { | 229 { |
| 230 MatchTester match(m_path, test.path()); | 230 MatchTester match(m_path, test.path()); |
| 231 return match.test(); | 231 return match.test(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace WebCore | 234 } // namespace WebCore |
| OLD | NEW |