[gnome-software/mwleeds/pwa-plugin: 4/4] fixup! Revive webapp support




commit b13cb3b6270bea306beb09dfe58d44def3ed0efc
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Thu Feb 3 16:47:18 2022 -0800

    fixup! Revive webapp support

 plugins/epiphany/gs-plugin-epiphany.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 49b816e04..19acb3c24 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -331,11 +331,11 @@ list_installed_apps_thread_cb (GTask        *task,
                const gchar *desktop_file_id = webapps[i];
                const gchar *desktop_path;
                const gchar *name;
-               const gchar *url;
+               const gchar *url = NULL;
                g_autofree char *icon_path = NULL;
                const gchar *exec;
                int argc;
-               g_auto (GStrv) argv = NULL;
+               g_auto(GStrv) argv = NULL;
                guint64 install_date = 0;
                g_autoptr(GsApp) app = NULL;
                g_autoptr(GDesktopAppInfo) desktop_info = NULL;
@@ -355,8 +355,10 @@ list_installed_apps_thread_cb (GTask        *task,
                /* This way of getting the URL is a bit hacky but it's what Epiphany does */
                exec = g_app_info_get_commandline (G_APP_INFO (desktop_info));
                if (g_shell_parse_argv (exec, &argc, &argv, NULL)) {
+                       g_assert (argc > 0);
                        url = argv[argc - 1];
-               } else {
+               }
+               if (!url || !g_uri_is_valid (url, G_URI_FLAGS_NONE, NULL)) {
                        g_warning ("Failed to parse URL for web app %s", desktop_file_id);
                        continue;
                }
@@ -460,7 +462,14 @@ gs_plugin_app_install (GsPlugin      *plugin,
                        else
                                continue;
 
+                       /* Serialize the icon as a #GBytesIcon since that's
+                        * what the dynamic launcher portal requires.
+                        */
                        stream = g_loadable_icon_load (G_LOADABLE_ICON (icon), 0, NULL, NULL, NULL);
+                       /* Icons are usually smaller than 1 MiB. Set a 10 MiB
+                        * limit so we can't use a huge amount of memory or hit
+                        * the D-Bus message size limit
+                        */
                        if (stream)
                                bytes = g_input_stream_read_bytes (stream, 10485760 /* 10 MiB */, NULL, NULL);
                        if (bytes)


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