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

Unified Diff: net/base/sdch_manager.cc

Issue 574283006: Fix dictionary domain check problem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed glitch from self-review. Created 6 years, 3 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
« no previous file with comments | « no previous file | net/base/sdch_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/sdch_manager.cc
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index 59589fb544723d386fa37019dd30a574cd8432d0..cc756a4585fd47a8592d288f875e6f1d85b7b6b4 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -13,6 +13,27 @@
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/url_request/url_request_http_job.h"
+namespace {
+
+void StripTrailingDot(GURL* gurl) {
+ std::string host(gurl->host());
+
+ if (host.empty())
+ return;
+
+ if (*host.rbegin() != '.')
+ return;
+
+ host.resize(host.size() - 1);
+
+ GURL::Replacements replacements;
+ replacements.SetHostStr(host);
+ *gurl = gurl->ReplaceComponents(replacements);
+ return;
+}
+
+} // namespace
+
namespace net {
//------------------------------------------------------------------------------
@@ -550,10 +571,14 @@ void SdchManager::AddSdchDictionary(const std::string& dictionary_text,
line_start = line_end + 1;
}
- if (!IsInSupportedDomain(dictionary_url))
+ // Narrow fix for http://crbug.com/389451.
+ GURL dictionary_url_normalized(dictionary_url);
+ StripTrailingDot(&dictionary_url_normalized);
+
+ if (!IsInSupportedDomain(dictionary_url_normalized))
return;
- if (!Dictionary::CanSet(domain, path, ports, dictionary_url))
+ if (!Dictionary::CanSet(domain, path, ports, dictionary_url_normalized))
return;
// TODO(jar): Remove these hacks to preclude a DOS attack involving piles of
@@ -574,7 +599,8 @@ void SdchManager::AddSdchDictionary(const std::string& dictionary_text,
<< " and server hash " << server_hash;
Dictionary* dictionary =
new Dictionary(dictionary_text, header_end + 2, client_hash,
- dictionary_url, domain, path, expiration, ports);
+ dictionary_url_normalized, domain,
+ path, expiration, ports);
dictionaries_[server_hash] = dictionary;
return;
}
« no previous file with comments | « no previous file | net/base/sdch_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698