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

Unified Diff: chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc

Issue 71303009: Fix browser crash when parsing invalid Settings Override extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed SettingsOverridePermissionTest.* Created 7 years, 1 month 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 | « no previous file | chrome/common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
diff --git a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
index 8eff8e449b037dd38ee7b9145d3136b45707a689..acd1a81b61b3a2277c0db8f21d142f6ed43a2ab4 100644
--- a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
+++ b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
@@ -62,6 +62,26 @@ std::vector<GURL> ParseStartupPage(const ChromeSettingsOverrides& overrides,
return urls;
}
+scoped_ptr<ChromeSettingsOverrides::Search_provider> ParseSearchEngine(
+ ChromeSettingsOverrides* overrides,
+ string16* error) {
+ if (!overrides->search_provider)
+ return scoped_ptr<ChromeSettingsOverrides::Search_provider>();
+ if (!CreateManifestURL(overrides->search_provider->favicon_url)) {
+ *error = extensions::ErrorUtils::FormatErrorMessageUTF16(
+ manifest_errors::kInvalidSearchEngineURL,
+ overrides->search_provider->favicon_url);
+ return scoped_ptr<ChromeSettingsOverrides::Search_provider>();
+ }
+ if (!CreateManifestURL(overrides->search_provider->search_url)) {
+ *error = extensions::ErrorUtils::FormatErrorMessageUTF16(
+ manifest_errors::kInvalidSearchEngineURL,
+ overrides->search_provider->search_url);
+ return scoped_ptr<ChromeSettingsOverrides::Search_provider>();
+ }
+ return overrides->search_provider.Pass();
+}
+
// A www. prefix is not informative and thus not worth the limited real estate
// in the permissions UI.
std::string RemoveWwwPrefix(const std::string& url) {
@@ -96,7 +116,7 @@ bool SettingsOverridesHandler::Parse(Extension* extension, string16* error) {
scoped_ptr<SettingsOverrides> info(new SettingsOverrides);
info->homepage = ParseHomepage(*settings, error);
- info->search_engine = settings->search_provider.Pass();
+ info->search_engine = ParseSearchEngine(settings.get(), error);
info->startup_pages = ParseStartupPage(*settings, error);
if (!info->homepage && !info->search_engine && info->startup_pages.empty()) {
*error = ASCIIToUTF16(manifest_errors::kInvalidEmptySettingsOverrides);
« no previous file with comments | « no previous file | chrome/common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698