[gnome-shell] extensionDownloader: Properly error out when downloading/parsing infos



commit 1d1359b58fdc91230494b0193ad7aa1a138220f5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Jun 15 22:38:55 2012 -0400

    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 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js
index b1c0810..e9f4952 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) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]