From 56bf1b7944f2c7b2a620b0e1476086b7e60f0da6 Mon Sep 17 00:00:00 2001 From: "aa@chromium.org" Date: Fri, 1 Oct 2010 17:58:56 +0000 Subject: Prevent apps from claiming "". The gallery would have prevented this before, but this makes it more explicit. BUG=56801 TEST=unit_tests --gtest_filter=ExtensionManifestTest.* Review URL: http://codereview.chromium.org/3524005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61198 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/extensions/extension.cc | 7 +++++++ chrome/common/extensions/extension_manifests_unittest.cc | 3 +++ .../data/extensions/manifest_tests/web_urls_invalid_4.json | 12 ++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 chrome/test/data/extensions/manifest_tests/web_urls_invalid_4.json diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index a9a8fc9..30a67c6 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -764,6 +764,13 @@ bool Extension::LoadExtent(const DictionaryValue* manifest, return false; } + // Do not allow authors to claim "". That would make no sense. + if (pattern.match_all_urls()) { + *error = ExtensionErrorUtils::FormatErrorMessage(value_error, + base::UintToString(i)); + return false; + } + // We do not allow authors to put wildcards in their paths. Instead, we // imply one at the end. if (pattern.path().find('*') != std::string::npos) { diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc index a4c3a3d..5cdd909 100644 --- a/chrome/common/extensions/extension_manifests_unittest.cc +++ b/chrome/common/extensions/extension_manifests_unittest.cc @@ -153,6 +153,9 @@ TEST_F(ExtensionManifestTest, AppWebUrls) { LoadAndExpectError("web_urls_invalid_3.json", ExtensionErrorUtils::FormatErrorMessage( errors::kInvalidWebURL, "0")); + LoadAndExpectError("web_urls_invalid_4.json", + ExtensionErrorUtils::FormatErrorMessage( + errors::kInvalidWebURL, "0")); scoped_ptr extension( LoadAndExpectSuccess("web_urls_default.json")); diff --git a/chrome/test/data/extensions/manifest_tests/web_urls_invalid_4.json b/chrome/test/data/extensions/manifest_tests/web_urls_invalid_4.json new file mode 100644 index 0000000..58634e3 --- /dev/null +++ b/chrome/test/data/extensions/manifest_tests/web_urls_invalid_4.json @@ -0,0 +1,12 @@ +{ + "name": "test", + "version": "1", + "app": { + "urls": [ + "" + ], + "launch": { + "web_url": "http://www.google.com/foo.html" + } + } +} -- cgit v1.1