From 1d1359b58fdc91230494b0193ad7aa1a138220f5 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 15 Jun 2012 22:38:55 -0400 Subject: [PATCH] extensionDownloader: Properly error out when downloading/parsing infos When the extension downloader was originally designed, the information downloading part was inserted at the last minute, along with the modal dialog as a security feature to make sure an extension didn't silently get installed on the user's machines either due to a security issue in the browser-plugin, or an XSS issue on the extensions website. Correct the mistake I made when writing the code; instead of dropping an error on the floor, log it correctly. This "bug" has already bitten a number of users who forgot to configure proxy settings in the control center. https://bugzilla.gnome.org/show_bug.cgi?id=679099 --- js/ui/extensionDownloader.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js index b1c0810a3..e9f49524c 100644 --- a/js/ui/extensionDownloader.js +++ b/js/ui/extensionDownloader.js @@ -28,12 +28,23 @@ function installExtensionFromUUID(uuid) { let message = Soup.form_request_new_from_hash('GET', REPOSITORY_URL_INFO, params); - _httpSession.queue_message(message, - function(session, message) { - let info = JSON.parse(message.response_body.data); - let dialog = new InstallExtensionDialog(uuid, info); - dialog.open(global.get_current_time()); - }); + _httpSession.queue_message(message, function(session, message) { + if (message.status_code != Soup.KnownStatusCode.OK) { + ExtensionSystem.logExtensionError(uuid, 'downloading info: ' + message.status_code); + return; + } + + let info; + try { + info = JSON.parse(message.response_body.data); + } catch (e) { + ExtensionSystem.logExtensionError(uuid, 'parsing info: ' + e); + return; + } + + let dialog = new InstallExtensionDialog(uuid, info); + dialog.open(global.get_current_time()); + }); } function uninstallExtensionFromUUID(uuid) { @@ -85,6 +96,12 @@ function gotExtensionZipFile(session, message, uuid) { GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, function(pid, status) { GLib.spawn_close_pid(pid); + if (status != 0) { + ExtensionSystem.logExtensionError(uuid, 'extract: could not extract'); + invocation.return_dbus_error('org.gnome.Shell.ExtractExtensionError', ''); + return; + } + // Add extension to 'enabled-extensions' for the user, always... let enabledExtensions = global.settings.get_strv(ExtensionSystem.ENABLED_EXTENSIONS_KEY); if (enabledExtensions.indexOf(uuid) == -1) {