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

Unified Diff: chrome/browser/extensions/extension.cc

Issue 27236: Enforce new id format (hex str of sha-1) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | « chrome/browser/extensions/extension.h ('k') | chrome/browser/extensions/extensions_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension.cc
===================================================================
--- chrome/browser/extensions/extension.cc (revision 10469)
+++ chrome/browser/extensions/extension.cc (working copy)
@@ -69,6 +69,8 @@
const char* Extension::kInvalidPluginsDirError =
"Invalid value for 'plugins_dir'.";
+const int Extension::kIdSize = 20; // SHA1 (160 bits) == 20 bytes
+
const std::string Extension::VersionString() const {
return version_->GetString();
}
@@ -172,22 +174,14 @@
*error = kInvalidIdError;
return false;
}
- // Verify that the id is legal. This test is basically verifying that it
- // is ASCII and doesn't have any path components in it.
- // TODO(erikkay): verify the actual id format - it will be more restrictive
- // than this. Perhaps just a hex string?
- if (!IsStringASCII(id_)) {
+
+ // Verify that the id is legal. The id is a hex string of the SHA-1 hash of
+ // the public key.
+ std::vector<uint8> id_bytes;
+ if (!HexStringToBytes(id_, &id_bytes) || id_bytes.size() != kIdSize) {
*error = kInvalidIdError;
return false;
}
- FilePath id_path;
- id_path = id_path.AppendASCII(id_);
- if ((id_path.value() == FilePath::kCurrentDirectory) ||
- (id_path.value() == FilePath::kParentDirectory) ||
- !(id_path.BaseName() == id_path)) {
- *error = kInvalidIdError;
- return false;
- }
// Initialize URL.
extension_url_ = GURL(std::string(chrome::kExtensionScheme) +
« no previous file with comments | « chrome/browser/extensions/extension.h ('k') | chrome/browser/extensions/extensions_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698