diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/page/UserContentURLPattern.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/page/UserContentURLPattern.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/3rdparty/webkit/WebCore/page/UserContentURLPattern.cpp b/src/3rdparty/webkit/WebCore/page/UserContentURLPattern.cpp index 1960131..5f0a311 100644 --- a/src/3rdparty/webkit/WebCore/page/UserContentURLPattern.cpp +++ b/src/3rdparty/webkit/WebCore/page/UserContentURLPattern.cpp @@ -30,19 +30,33 @@ namespace WebCore { -bool UserContentURLPattern::matchesPatterns(const KURL& url, const Vector<String>& patterns) +bool UserContentURLPattern::matchesPatterns(const KURL& url, const Vector<String>* whitelist, const Vector<String>* blacklist) { - // Treat no patterns at all as though a pattern of * was specified. - if (patterns.isEmpty()) - return true; + // In order for a URL to be a match it has to be present in the whitelist and not present in the blacklist. + // If there is no whitelist at all, then all URLs are assumed to be in the whitelist. + bool matchesWhitelist = !whitelist || whitelist->isEmpty(); + if (!matchesWhitelist) { + for (unsigned i = 0; i < whitelist->size(); ++i) { + UserContentURLPattern contentPattern(whitelist->at(i)); + if (contentPattern.matches(url)) { + matchesWhitelist = true; + break; + } + } + } - for (unsigned i = 0; i < patterns.size(); ++i) { - UserContentURLPattern contentPattern(patterns[i]); - if (contentPattern.matches(url)) - return true; + bool matchesBlacklist = false; + if (blacklist) { + for (unsigned i = 0; i < blacklist->size(); ++i) { + UserContentURLPattern contentPattern(blacklist->at(i)); + if (contentPattern.matches(url)) { + matchesBlacklist = true; + break; + } + } } - return false; + return matchesWhitelist && !matchesBlacklist; } bool UserContentURLPattern::parse(const String& pattern) |