summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 23:48:49 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-30 23:48:49 +0000
commit657cab96e02528adfe513c90c4f07a036d92bfe6 (patch)
tree20cb65a55e78e7e6183117b79dd2efe2a259ba6b /chrome/common/extensions
parent6d9246446121d198c76a0445122757a8dca6709f (diff)
downloadchromium_src-657cab96e02528adfe513c90c4f07a036d92bfe6.zip
chromium_src-657cab96e02528adfe513c90c4f07a036d92bfe6.tar.gz
chromium_src-657cab96e02528adfe513c90c4f07a036d92bfe6.tar.bz2
When input is "" (or " " with trim_whitespace true), SplitString() should return an empty vector, not a vector of one empty string.
Brett and I discussed this for a while and felt this would be wise, whereas dropping all empty segments entirely (e.g. converting "a,,b" to a vector of two elements instead of three) was probably unwise. This also simplifies the code some. Fixing this also required changing the code in mime_util.cc to handle empty vectors to "are codecs valid" oracle functions (in which case we return false). I also fixed some style issues there. It also required avoiding passing the empty string in a test in extension_api_unittest.cc; Aaron assures me that this code is not expected to be defensive against such inputs, but at his suggestion I also added some CHECK()s to the API. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9960004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/api/extension_api.cc2
-rw-r--r--chrome/common/extensions/api/extension_api_unittest.cc1
2 files changed, 2 insertions, 1 deletions
diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc
index 6bbd8df..3178975 100644
--- a/chrome/common/extensions/api/extension_api.cc
+++ b/chrome/common/extensions/api/extension_api.cc
@@ -268,10 +268,12 @@ bool ExtensionAPI::IsPrivileged(const std::string& full_name) {
std::vector<std::string> split;
base::SplitString(full_name, '.', &split);
std::reverse(split.begin(), split.end());
+ CHECK(!split.empty()); // |full_name| was empty or only whitespace.
api_name = split.back();
split.pop_back();
if (api_name == "experimental") {
+ CHECK(!split.empty()); // |full_name| was "experimental" alone.
api_name += "." + split.back();
split.pop_back();
}
diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc
index bf240e1..1c5a22e3 100644
--- a/chrome/common/extensions/api/extension_api_unittest.cc
+++ b/chrome/common/extensions/api/extension_api_unittest.cc
@@ -26,7 +26,6 @@ TEST(ExtensionAPI, IsPrivileged) {
EXPECT_TRUE(extension_api.IsPrivileged("extension.lastError"));
// Default unknown names to privileged for paranoia's sake.
- EXPECT_TRUE(extension_api.IsPrivileged(""));
EXPECT_TRUE(extension_api.IsPrivileged("<unknown-namespace>"));
EXPECT_TRUE(extension_api.IsPrivileged("extension.<unknown-member>"));