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

Unified Diff: extensions/browser/api/runtime/runtime_api.cc

Issue 1283193003: Restrict chrome.runtime.setUninstallURL to http(s) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2454
Patch Set: Created 5 years, 4 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
Index: extensions/browser/api/runtime/runtime_api.cc
diff --git a/extensions/browser/api/runtime/runtime_api.cc b/extensions/browser/api/runtime/runtime_api.cc
index d69d518172bd6038ac79d2211865f9ce2b4e9699..802caac94502a5db88a59bfcc0ffa24c20a1c210 100644
--- a/extensions/browser/api/runtime/runtime_api.cc
+++ b/extensions/browser/api/runtime/runtime_api.cc
@@ -54,7 +54,7 @@ const char kInstallReasonUpdate[] = "update";
const char kInstallReasonInstall[] = "install";
const char kInstallReasonSharedModuleUpdate[] = "shared_module_update";
const char kInstallPreviousVersion[] = "previousVersion";
-const char kInvalidUrlError[] = "Invalid URL.";
+const char kInvalidUrlError[] = "Invalid URL: \"*\".";
const char kPlatformInfoUnavailable[] = "Platform information unavailable.";
const char kUpdatesDisabledError[] = "Autoupdate is not enabled.";
@@ -401,8 +401,11 @@ void RuntimeEventRouter::OnExtensionUninstalled(
GURL uninstall_url(
GetUninstallURL(ExtensionPrefs::Get(context), extension_id));
- if (uninstall_url.is_empty())
+ if (!uninstall_url.SchemeIsHTTPOrHTTPS()) {
+ // Previous versions of Chrome allowed non-http(s) URLs to be stored in the
+ // prefs. Now they're disallowed, but the old data may still exist.
return;
+ }
RuntimeAPI::GetFactoryInstance()->Get(context)->OpenURL(uninstall_url);
}
@@ -444,10 +447,8 @@ ExtensionFunction::ResponseAction RuntimeSetUninstallURLFunction::Run() {
std::string url_string;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url_string));
- GURL url(url_string);
- if (!url.is_valid()) {
- return RespondNow(
- Error(ErrorUtils::FormatErrorMessage(kInvalidUrlError, url_string)));
+ if (!url_string.empty() && !GURL(url_string).SchemeIsHTTPOrHTTPS()) {
+ return RespondNow(Error(kInvalidUrlError, url_string));
}
SetUninstallURL(
ExtensionPrefs::Get(browser_context()), extension_id(), url_string);
« no previous file with comments | « chrome/test/data/extensions/api_test/runtime/uninstall_url/test.js ('k') | extensions/common/api/runtime.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698