Chromium Code Reviews

Unified Diff: chrome/installer/util/delete_after_reboot_helper.cc

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: chrome/installer/util/delete_after_reboot_helper.cc
diff --git a/chrome/installer/util/delete_after_reboot_helper.cc b/chrome/installer/util/delete_after_reboot_helper.cc
index 513cd3c3aa8ada78111db4b467e5fc29cb013a15..1dc9273fc510c3299cd80e22f1a8bcb1abb09810 100644
--- a/chrome/installer/util/delete_after_reboot_helper.cc
+++ b/chrome/installer/util/delete_after_reboot_helper.cc
@@ -326,20 +326,25 @@ HRESULT GetPendingMovesValue(std::vector<PendingMove>* pending_moves) {
bool MatchPendingDeletePath(const base::FilePath& short_form_needle,
const base::FilePath& reg_path) {
// Stores the path stored in each entry.
- std::wstring match_path(reg_path.value());
+ base::string16 match_path(reg_path.value());
// First chomp the prefix since that will mess up GetShortPathName.
- std::wstring prefix(L"\\??\\");
- if (base::StartsWith(match_path, prefix, false))
+ base::string16 prefix(L"\\??\\");
+ if (base::StartsWith(match_path, prefix, base::CompareCase::SENSITIVE))
match_path = match_path.substr(4);
// Get the short path name of the entry.
base::FilePath short_match_path(GetShortPathName(base::FilePath(match_path)));
- // Now compare the paths. If it isn't one we're looking for, add it
- // to the list to keep.
- return base::StartsWith(short_match_path.value(), short_form_needle.value(),
- false);
+ // Now compare the paths. Return true if short_form_needle is a
+ // case-insensitive prefix of short_match_path.
+ if (short_match_path.value().size() < short_form_needle.value().size())
+ return false;
+ DWORD prefix_len = static_cast<DWORD>(short_form_needle.value().size());
+ return ::CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE,
+ short_match_path.value().data(), prefix_len,
+ short_form_needle.value().data(), prefix_len) ==
+ CSTR_EQUAL;
}
// Removes all pending moves for the given |directory| and any contained

Powered by Google App Engine