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

Side by Side Diff: chrome/browser/enumerate_modules_model_win.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, 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 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 #include "chrome/browser/enumerate_modules_model_win.h" 5 #include "chrome/browser/enumerate_modules_model_win.h"
6 6
7 #include <Tlhelp32.h> 7 #include <Tlhelp32.h>
8 #include <wintrust.h> 8 #include <wintrust.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 682
683 void ModuleEnumerator::CollapsePath(Module* entry) { 683 void ModuleEnumerator::CollapsePath(Module* entry) {
684 // Take the path and see if we can use any of the substitution values 684 // Take the path and see if we can use any of the substitution values
685 // from the vector constructed above to replace c:\windows with, for 685 // from the vector constructed above to replace c:\windows with, for
686 // example, %systemroot%. The most collapsed path (the one with the 686 // example, %systemroot%. The most collapsed path (the one with the
687 // minimum length) wins. 687 // minimum length) wins.
688 size_t min_length = MAXINT; 688 size_t min_length = MAXINT;
689 base::string16 location = entry->location; 689 base::string16 location = entry->location;
690 for (PathMapping::const_iterator mapping = path_mapping_.begin(); 690 for (PathMapping::const_iterator mapping = path_mapping_.begin();
691 mapping != path_mapping_.end(); ++mapping) { 691 mapping != path_mapping_.end(); ++mapping) {
692 base::string16 prefix = mapping->first; 692 const base::string16& prefix = mapping->first;
693 if (base::StartsWith(location, prefix, false)) { 693 if (base::StartsWith(base::i18n::ToLower(location),
694 base::i18n::ToLower(prefix),
695 base::CompareCase::SENSITIVE)) {
694 base::string16 new_location = mapping->second + 696 base::string16 new_location = mapping->second +
695 location.substr(prefix.length() - 1); 697 location.substr(prefix.length() - 1);
696 size_t length = new_location.length() - mapping->second.length(); 698 size_t length = new_location.length() - mapping->second.length();
697 if (length < min_length) { 699 if (length < min_length) {
698 entry->location = new_location; 700 entry->location = new_location;
699 min_length = length; 701 min_length = length;
700 } 702 }
701 } 703 }
702 } 704 }
703 } 705 }
(...skipping 23 matching lines...) Expand all
727 module->recommended_action = kModuleBlacklist[i].help_tip; 729 module->recommended_action = kModuleBlacklist[i].help_tip;
728 break; 730 break;
729 } 731 }
730 } 732 }
731 733
732 // Modules loaded from these locations are frequently malicious 734 // Modules loaded from these locations are frequently malicious
733 // and notorious for changing frequently so they are not good candidates 735 // and notorious for changing frequently so they are not good candidates
734 // for blacklisting individually. Mark them as suspicious if we haven't 736 // for blacklisting individually. Mark them as suspicious if we haven't
735 // classified them as bad yet. 737 // classified them as bad yet.
736 if (module->status == NOT_MATCHED || module->status == GOOD) { 738 if (module->status == NOT_MATCHED || module->status == GOOD) {
737 if (base::StartsWith(module->location, L"%temp%", false) || 739 if (base::StartsWith(module->location, L"%temp%",
738 base::StartsWith(module->location, L"%tmp%", false)) { 740 base::CompareCase::INSENSITIVE_ASCII) ||
741 base::StartsWith(module->location, L"%tmp%",
742 base::CompareCase::INSENSITIVE_ASCII)) {
739 module->status = SUSPECTED_BAD; 743 module->status = SUSPECTED_BAD;
740 } 744 }
741 } 745 }
742 } 746 }
743 } 747 }
744 748
745 void ModuleEnumerator::ReportBack() { 749 void ModuleEnumerator::ReportBack() {
746 if (!limited_mode_) 750 if (!limited_mode_)
747 DCHECK(BrowserThread::CurrentlyOn(callback_thread_id_)); 751 DCHECK(BrowserThread::CurrentlyOn(callback_thread_id_));
748 observer_->DoneScanning(); 752 observer_->DoneScanning();
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 GenerateHash(base::WideToUTF8(module.location), &location); 1069 GenerateHash(base::WideToUTF8(module.location), &location);
1066 GenerateHash(base::WideToUTF8(module.description), &description); 1070 GenerateHash(base::WideToUTF8(module.description), &description);
1067 GenerateHash(base::WideToUTF8(module.digital_signer), &signer); 1071 GenerateHash(base::WideToUTF8(module.digital_signer), &signer);
1068 1072
1069 base::string16 url = 1073 base::string16 url =
1070 l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, 1074 l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS,
1071 base::ASCIIToUTF16(filename), base::ASCIIToUTF16(location), 1075 base::ASCIIToUTF16(filename), base::ASCIIToUTF16(location),
1072 base::ASCIIToUTF16(description), base::ASCIIToUTF16(signer)); 1076 base::ASCIIToUTF16(description), base::ASCIIToUTF16(signer));
1073 return GURL(base::UTF16ToUTF8(url)); 1077 return GURL(base::UTF16ToUTF8(url));
1074 } 1078 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/variations/experiment_labels.cc » ('j') | chrome/common/variations/experiment_labels.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698