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

Unified Diff: extensions/browser/verified_contents.cc

Issue 585583003: Fix case-sensitivity problems in extension content verification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove old code Created 6 years, 3 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 | « extensions/browser/verified_contents.h ('k') | extensions/browser/verified_contents_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/verified_contents.cc
diff --git a/extensions/browser/verified_contents.cc b/extensions/browser/verified_contents.cc
index 47c94662a166ca18d999ef9a32992318d9b4e9ad..d9ff75c2abd5a70a9a80b8f8936f61a6b9bc43ca 100644
--- a/extensions/browser/verified_contents.cc
+++ b/extensions/browser/verified_contents.cc
@@ -186,8 +186,9 @@ bool VerifiedContents::InitFrom(const base::FilePath& path,
return false;
base::FilePath file_path =
base::FilePath::FromUTF8Unsafe(file_path_string);
- root_hashes_[file_path] = std::string();
- root_hashes_[file_path].swap(root_hash);
+ RootHashes::iterator i = root_hashes_.insert(std::make_pair(
+ base::StringToLowerASCII(file_path.value()), std::string()));
+ i->second.swap(root_hash);
}
break;
@@ -195,13 +196,24 @@ bool VerifiedContents::InitFrom(const base::FilePath& path,
return true;
}
-const std::string* VerifiedContents::GetTreeHashRoot(
- const base::FilePath& relative_path) {
- std::map<base::FilePath, std::string>::const_iterator i =
- root_hashes_.find(relative_path.NormalizePathSeparatorsTo('/'));
- if (i == root_hashes_.end())
- return NULL;
- return &i->second;
+bool VerifiedContents::HasTreeHashRoot(
+ const base::FilePath& relative_path) const {
+ base::FilePath::StringType path = base::StringToLowerASCII(
+ relative_path.NormalizePathSeparatorsTo('/').value());
+ return root_hashes_.find(path) != root_hashes_.end();
+}
+
+bool VerifiedContents::TreeHashRootEquals(const base::FilePath& relative_path,
+ const std::string& expected) const {
+ base::FilePath::StringType path = base::StringToLowerASCII(
+ relative_path.NormalizePathSeparatorsTo('/').value());
+ for (RootHashes::const_iterator i = root_hashes_.find(path);
+ i != root_hashes_.end();
+ ++i) {
+ if (expected == i->second)
+ return true;
+ }
+ return false;
}
// We're loosely following the "JSON Web Signature" draft spec for signing
« no previous file with comments | « extensions/browser/verified_contents.h ('k') | extensions/browser/verified_contents_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698