summaryrefslogtreecommitdiffstats
path: root/net/base/sdch_manager.cc
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 19:06:43 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 19:06:43 +0000
commitf24ab372e7f2ace6a67e0d1d3fc02e793202d8e9 (patch)
tree2f1ec6590be11056b1a808369c836a707c984b13 /net/base/sdch_manager.cc
parent66b2bc1ccd6a7d41b71b602b2983aa81527f9c8f (diff)
downloadchromium_src-f24ab372e7f2ace6a67e0d1d3fc02e793202d8e9.zip
chromium_src-f24ab372e7f2ace6a67e0d1d3fc02e793202d8e9.tar.gz
chromium_src-f24ab372e7f2ace6a67e0d1d3fc02e793202d8e9.tar.bz2
Revert 3024, broke mac build.
Review URL: http://codereview.chromium.org/6351 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/sdch_manager.cc')
-rw-r--r--net/base/sdch_manager.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index de1e0b0..6c8bce3 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -214,6 +214,18 @@ void SdchManager::UrlSafeBase64Encode(const std::string& input,
// Security functions restricting loads and use of dictionaries.
// static
+int SdchManager::Dictionary::GetPortIncludingDefault(const GURL& url) {
+ std::string port(url.port());
+ if (port.length())
+ return StringToInt(port);
+ if (url.scheme() == "http")
+ return 80; // Default port value.
+ // TODO(jar): If sdch supports other schemes, then write a general function
+ // or surface functionality hidden in url_cannon_stdurl.cc into url_canon.h.
+ return -1;
+}
+
+// static
bool SdchManager::Dictionary::CanSet(const std::string& domain,
const std::string& path,
const std::set<int> ports,
@@ -244,7 +256,7 @@ bool SdchManager::Dictionary::CanSet(const std::string& domain,
// TODO(jar): Enforce item 4 above.
if (!ports.empty()
- && 0 == ports.count(dictionary_url.EffectiveIntPort()))
+ && 0 == ports.count(GetPortIncludingDefault(dictionary_url)))
return false;
return true;
}
@@ -264,7 +276,7 @@ bool SdchManager::Dictionary::CanUse(const GURL referring_url) {
if (!DomainMatch(referring_url, domain_))
return false;
if (!ports_.empty()
- && 0 == ports_.count(referring_url.EffectiveIntPort()))
+ && 0 == ports_.count(GetPortIncludingDefault(referring_url)))
return false;
if (path_.size() && !PathMatch(referring_url.path(), path_))
return false;
@@ -290,7 +302,7 @@ bool SdchManager::Dictionary::CanAdvertise(const GURL& target_url) {
*/
if (!DomainMatch(target_url, domain_))
return false;
- if (!ports_.empty() && 0 == ports_.count(target_url.EffectiveIntPort()))
+ if (!ports_.empty() && 0 == ports_.count(GetPortIncludingDefault(target_url)))
return false;
if (path_.size() && !PathMatch(target_url.path(), path_))
return false;