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

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

Issue 1746303002: Replace std::string::find with base::StartsWith when comparing cookie paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove new test case Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 return; 1204 return;
1205 1205
1206 CookieOptions options; 1206 CookieOptions options;
1207 options.set_include_httponly(); 1207 options.set_include_httponly();
1208 options.set_include_same_site(); 1208 options.set_include_same_site();
1209 // Get the cookies for this host and its domain(s). 1209 // Get the cookies for this host and its domain(s).
1210 std::vector<CanonicalCookie*> cookies; 1210 std::vector<CanonicalCookie*> cookies;
1211 FindCookiesForHostAndDomain(url, options, &cookies); 1211 FindCookiesForHostAndDomain(url, options, &cookies);
1212 std::set<CanonicalCookie*> matching_cookies; 1212 std::set<CanonicalCookie*> matching_cookies;
1213 1213
1214 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); 1214 for (const auto& cookie : cookies) {
1215 it != cookies.end(); ++it) { 1215 if (cookie->Name() != cookie_name)
1216 if ((*it)->Name() != cookie_name)
1217 continue; 1216 continue;
1218 if (url.path().find((*it)->Path())) 1217 if (!cookie->IsOnPath(url.path()))
mmenke 2016/03/02 20:02:01 Just happened to notice this bug when cleaning up
Mike West 2016/03/03 18:56:28 \o/
1219 continue; 1218 continue;
1220 matching_cookies.insert(*it); 1219 matching_cookies.insert(cookie);
1221 } 1220 }
1222 1221
1223 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { 1222 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) {
1224 CookieMap::iterator curit = it; 1223 CookieMap::iterator curit = it;
1225 ++it; 1224 ++it;
1226 if (matching_cookies.find(curit->second) != matching_cookies.end()) { 1225 if (matching_cookies.find(curit->second) != matching_cookies.end()) {
1227 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPLICIT); 1226 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPLICIT);
1228 } 1227 }
1229 } 1228 }
1230 } 1229 }
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 it != hook_map_.end(); ++it) { 2407 it != hook_map_.end(); ++it) {
2409 std::pair<GURL, std::string> key = it->first; 2408 std::pair<GURL, std::string> key = it->first;
2410 if (cookie.IncludeForRequestURL(key.first, opts) && 2409 if (cookie.IncludeForRequestURL(key.first, opts) &&
2411 cookie.Name() == key.second) { 2410 cookie.Name() == key.second) {
2412 it->second->Notify(cookie, removed); 2411 it->second->Notify(cookie, removed);
2413 } 2412 }
2414 } 2413 }
2415 } 2414 }
2416 2415
2417 } // namespace net 2416 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698