Chromium Code Reviews

Side by Side Diff: net/base/cookie_monster.cc

Issue 7155016: Remove out-of-date comments that refer to old cookie implementations and specs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 175 matching lines...)
186 // We match IE/Firefox in allowing a domain=IPADDR if it matches the url 186 // We match IE/Firefox in allowing a domain=IPADDR if it matches the url
187 // ip address hostname exactly. It should be treated as a host cookie. 187 // ip address hostname exactly. It should be treated as a host cookie.
188 if (domain_string.empty() || 188 if (domain_string.empty() ||
189 (url.HostIsIPAddress() && url_host == domain_string)) { 189 (url.HostIsIPAddress() && url_host == domain_string)) {
190 *result = url_host; 190 *result = url_host;
191 DCHECK(CookieMonster::DomainIsHostOnly(*result)); 191 DCHECK(CookieMonster::DomainIsHostOnly(*result));
192 return true; 192 return true;
193 } 193 }
194 194
195 // Get the normalized domain specified in cookie line. 195 // Get the normalized domain specified in cookie line.
196 // Note: The RFC says we can reject a cookie if the domain
197 // attribute does not start with a dot. IE/FF/Safari however, allow a cookie
198 // of the form domain=my.domain.com, treating it the same as
199 // domain=.my.domain.com -- for compatibility we do the same here. Firefox
200 // also treats domain=.....my.domain.com like domain=.my.domain.com, but
201 // neither IE nor Safari do this, and we don't either.
202 url_canon::CanonHostInfo ignored; 196 url_canon::CanonHostInfo ignored;
203 std::string cookie_domain(CanonicalizeHost(domain_string, &ignored)); 197 std::string cookie_domain(CanonicalizeHost(domain_string, &ignored));
204 if (cookie_domain.empty()) 198 if (cookie_domain.empty())
205 return false; 199 return false;
206 if (cookie_domain[0] != '.') 200 if (cookie_domain[0] != '.')
207 cookie_domain = "." + cookie_domain; 201 cookie_domain = "." + cookie_domain;
208 202
209 // Ensure |url| and |cookie_domain| have the same domain+registry. 203 // Ensure |url| and |cookie_domain| have the same domain+registry.
210 const std::string url_scheme(url.scheme()); 204 const std::string url_scheme(url.scheme());
211 const std::string url_domain_and_registry( 205 const std::string url_domain_and_registry(
(...skipping 1607 matching lines...)
1819 const std::string::const_iterator& end, 1813 const std::string::const_iterator& end,
1820 std::string::const_iterator* value_start, 1814 std::string::const_iterator* value_start,
1821 std::string::const_iterator* value_end) { 1815 std::string::const_iterator* value_end) {
1822 DCHECK(it && value_start && value_end); 1816 DCHECK(it && value_start && value_end);
1823 1817
1824 // Seek past any whitespace that might in-between the token and value. 1818 // Seek past any whitespace that might in-between the token and value.
1825 SeekPast(it, end, kWhitespace); 1819 SeekPast(it, end, kWhitespace);
1826 // value_start should point at the first character of the value. 1820 // value_start should point at the first character of the value.
1827 *value_start = *it; 1821 *value_start = *it;
1828 1822
1829 // It is unclear exactly how quoted string values should be handled.
1830 // Major browsers do different things, for example, Firefox supports
1831 // semicolons embedded in a quoted value, while IE does not. Looking at
1832 // the specs, RFC 2109 and 2965 allow for a quoted-string as the value.
1833 // However, these specs were apparently written after browsers had
1834 // implemented cookies, and they seem very distant from the reality of
1835 // what is actually implemented and used on the web. The original spec
1836 // from Netscape is possibly what is closest to the cookies used today.
1837 // This spec didn't have explicit support for double quoted strings, and
1838 // states that ; is not allowed as part of a value. We had originally
1839 // implement the Firefox behavior (A="B;C"; -> A="B;C";). However, since
1840 // there is no standard that makes sense, we decided to follow the behavior
1841 // of IE and Safari, which is closer to the original Netscape proposal.
1842 // This means that A="B;C" -> A="B;. This also makes the code much simpler
1843 // and reduces the possibility for invalid cookies, where other browsers
1844 // like Opera currently reject those invalid cookies (ex A="B" "C";).
1845
1846 // Just look for ';' to terminate ('=' allowed). 1823 // Just look for ';' to terminate ('=' allowed).
1847 // We can hit the end, maybe they didn't terminate. 1824 // We can hit the end, maybe they didn't terminate.
1848 SeekTo(it, end, kValueSeparator); 1825 SeekTo(it, end, kValueSeparator);
1849 1826
1850 // Will be pointed at the ; seperator or the end. 1827 // Will be pointed at the ; seperator or the end.
1851 *value_end = *it; 1828 *value_end = *it;
1852 1829
1853 // Ignore any unwanted whitespace after the value. 1830 // Ignore any unwanted whitespace after the value.
1854 if (*value_end != *value_start) { // Could have an empty value 1831 if (*value_end != *value_start) { // Could have an empty value
1855 --(*value_end); 1832 --(*value_end);
(...skipping 317 matching lines...)
2173 std::string CookieMonster::CanonicalCookie::DebugString() const { 2150 std::string CookieMonster::CanonicalCookie::DebugString() const {
2174 return base::StringPrintf( 2151 return base::StringPrintf(
2175 "name: %s value: %s domain: %s path: %s creation: %" 2152 "name: %s value: %s domain: %s path: %s creation: %"
2176 PRId64, 2153 PRId64,
2177 name_.c_str(), value_.c_str(), 2154 name_.c_str(), value_.c_str(),
2178 domain_.c_str(), path_.c_str(), 2155 domain_.c_str(), path_.c_str(),
2179 static_cast<int64>(creation_date_.ToTimeT())); 2156 static_cast<int64>(creation_date_.ToTimeT()));
2180 } 2157 }
2181 2158
2182 } // namespace 2159 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine