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

Unified Diff: net/cookies/canonical_cookie.cc

Issue 1766613002: Revert of Replace std::string::find with base::StartsWith when comparing cookie paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/cookies/cookie_monster.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/canonical_cookie.cc
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc
index 0a5e794fe81cdbea370de2ad45c467d900707fbe..fff3fa44b928cf95f2052cef60c7a1f4ca3cc753 100644
--- a/net/cookies/canonical_cookie.cc
+++ b/net/cookies/canonical_cookie.cc
@@ -47,7 +47,6 @@
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
-#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/parsed_cookie.h"
@@ -350,14 +349,15 @@
// was longer, the same length, or shorter than the length of the url path.
// I think the approach below is simpler.
- // Make sure the cookie path is a prefix of the url path. If the url path is
- // shorter than the cookie path, then the cookie path can't be a prefix.
- if (!base::StartsWith(url_path, path_, base::CompareCase::SENSITIVE))
- return false;
-
- // |url_path| is >= |path_|, and |path_| is a prefix of |url_path|. If they
- // are the are the same length then they are identical, otherwise need an
- // additional check:
+ // Make sure the cookie path is a prefix of the url path. If the
+ // url path is shorter than the cookie path, then the cookie path
+ // can't be a prefix.
+ if (url_path.find(path_) != 0)
+ return false;
+
+ // Now we know that url_path is >= cookie_path, and that cookie_path
+ // is a prefix of url_path. If they are the are the same length then
+ // they are identical, otherwise we need an additional check:
// In order to avoid in correctly matching a cookie path of /blah
// with a request path of '/blahblah/', we need to make sure that either
@@ -365,9 +365,8 @@
// in the url path. Since we know that the url path length is greater
// than the cookie path length, it's safe to index one byte past.
if (path_.length() != url_path.length() && path_.back() != '/' &&
- url_path[path_.length()] != '/') {
- return false;
- }
+ url_path[path_.length()] != '/')
+ return false;
return true;
}
« no previous file with comments | « no previous file | net/cookies/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698