OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2660 bool CookieMonster::CanonicalCookie::IsOnPath( | 2660 bool CookieMonster::CanonicalCookie::IsOnPath( |
2661 const std::string& url_path) const { | 2661 const std::string& url_path) const { |
2662 | 2662 |
2663 // A zero length would be unsafe for our trailing '/' checks, and | 2663 // A zero length would be unsafe for our trailing '/' checks, and |
2664 // would also make no sense for our prefix match. The code that | 2664 // would also make no sense for our prefix match. The code that |
2665 // creates a CanonicalCookie should make sure the path is never zero length, | 2665 // creates a CanonicalCookie should make sure the path is never zero length, |
2666 // but we double check anyway. | 2666 // but we double check anyway. |
2667 if (path_.empty()) | 2667 if (path_.empty()) |
2668 return false; | 2668 return false; |
2669 | 2669 |
2670 // The Mozilla code broke it into 3 cases, if it's strings lengths | 2670 // The Mozilla code broke it into 3 cases, if its strings lengths |
mmenke
2012/03/28 23:54:37
"its strings lengths" should presumably be "its st
| |
2671 // are less than, equal, or greater. I think this is simpler: | 2671 // are less than, equal, or greater. I think this is simpler: |
2672 | 2672 |
2673 // Make sure the cookie path is a prefix of the url path. If the | 2673 // Make sure the cookie path is a prefix of the url path. If the |
2674 // url path is shorter than the cookie path, then the cookie path | 2674 // url path is shorter than the cookie path, then the cookie path |
2675 // can't be a prefix. | 2675 // can't be a prefix. |
2676 if (url_path.find(path_) != 0) | 2676 if (url_path.find(path_) != 0) |
2677 return false; | 2677 return false; |
2678 | 2678 |
2679 // Now we know that url_path is >= cookie_path, and that cookie_path | 2679 // Now we know that url_path is >= cookie_path, and that cookie_path |
2680 // is a prefix of url_path. If they are the are the same length then | 2680 // is a prefix of url_path. If they are the are the same length then |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2731 std::string CookieMonster::CanonicalCookie::DebugString() const { | 2731 std::string CookieMonster::CanonicalCookie::DebugString() const { |
2732 return base::StringPrintf( | 2732 return base::StringPrintf( |
2733 "name: %s value: %s domain: %s path: %s creation: %" | 2733 "name: %s value: %s domain: %s path: %s creation: %" |
2734 PRId64, | 2734 PRId64, |
2735 name_.c_str(), value_.c_str(), | 2735 name_.c_str(), value_.c_str(), |
2736 domain_.c_str(), path_.c_str(), | 2736 domain_.c_str(), path_.c_str(), |
2737 static_cast<int64>(creation_date_.ToTimeT())); | 2737 static_cast<int64>(creation_date_.ToTimeT())); |
2738 } | 2738 } |
2739 | 2739 |
2740 } // namespace | 2740 } // namespace |
OLD | NEW |