Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6095)

Unified Diff: chrome/browser/privacy_blacklist/blacklist.cc

Issue 523137: Also match against the query string if present. (Closed)
Patch Set: updates Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/privacy_blacklist/blacklist.cc
diff --git a/chrome/browser/privacy_blacklist/blacklist.cc b/chrome/browser/privacy_blacklist/blacklist.cc
index 1bec742637c0c0032310c8b6a94e673d362cd389..f5155704447fec4277a07e45fe9b212d6765db27 100644
--- a/chrome/browser/privacy_blacklist/blacklist.cc
+++ b/chrome/browser/privacy_blacklist/blacklist.cc
@@ -60,6 +60,7 @@ unsigned int Blacklist::String2Attribute(const std::string& s) {
return 0;
}
+// static
bool Blacklist::Matches(const std::string& pattern, const std::string& url) {
if (pattern.size() > url.size())
return false;
@@ -174,7 +175,7 @@ void Blacklist::AddProvider(Provider* provider) {
// Returns a pointer to the Blacklist-owned entry which matches the given
// URL. If no matching Entry is found, returns null.
-Blacklist::Match* Blacklist::findMatch(const GURL& url) const {
+Blacklist::Match* Blacklist::FindMatch(const GURL& url) const {
// Never match something which is not http, https or ftp.
// TODO(idanan): Investigate if this would be an inclusion test instead of an
// exclusion test and if there are other schemes to test for.
@@ -182,10 +183,11 @@ Blacklist::Match* Blacklist::findMatch(const GURL& url) const {
!url.SchemeIs(chrome::kHttpsScheme) &&
!url.SchemeIs(chrome::kFtpScheme))
return 0;
+ std::string url_spec = GetURLAsString(url);
Match* match = NULL;
for (EntryList::const_iterator i = blacklist_.begin();
i != blacklist_.end(); ++i) {
- if (Matches((*i)->pattern(), url.host() + url.path())) {
+ if (Matches((*i)->pattern(), url_spec)) {
if (!match)
match = new Match;
match->AddEntry(i->get());
@@ -194,6 +196,15 @@ Blacklist::Match* Blacklist::findMatch(const GURL& url) const {
return match;
}
+// static
+std::string Blacklist::GetURLAsString(const GURL& url) {
+ std::string url_spec = url.host() + url.path();
+ if (!url.query().empty())
+ url_spec = url_spec + "?" + url.query();
+
+ return url_spec;
+}
+
std::string Blacklist::StripCookies(const std::string& header) {
return net::HttpUtil::StripHeaders(header, cookie_headers, 2);
}

Powered by Google App Engine
This is Rietveld 408576698