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

Unified Diff: components/os_crypt/os_crypt_posix.cc

Issue 2121513002: Replace string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typos Created 4 years, 5 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
Index: components/os_crypt/os_crypt_posix.cc
diff --git a/components/os_crypt/os_crypt_posix.cc b/components/os_crypt/os_crypt_posix.cc
index 44f04b3801fead7d45d2758260c9721db6bf9334..24a411e9bd6b1461e4f942f0723ed97b8eaa22e3 100644
--- a/components/os_crypt/os_crypt_posix.cc
+++ b/components/os_crypt/os_crypt_posix.cc
@@ -9,6 +9,7 @@
#include <memory>
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "crypto/encryptor.h"
#include "crypto/symmetric_key.h"
@@ -118,7 +119,8 @@ bool OSCrypt::DecryptString(const std::string& ciphertext,
// old data saved as clear text and we'll return it directly.
// Credit card numbers are current legacy data, so false match with prefix
// won't happen.
- if (ciphertext.find(kObfuscationPrefix) != 0) {
+ if (!base::StartsWith(ciphertext, kObfuscationPrefix,
+ base::CompareCase::SENSITIVE)) {
*plaintext = ciphertext;
return true;
}

Powered by Google App Engine
This is Rietveld 408576698