[epiphany/fix-webapp-app-id-confusion] Fix web app GApplication ID calculation




commit 48987ceb8823e2cdaef71932025ff9a757ea77ce
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Wed Jan 19 14:47:09 2022 -0800

    Fix web app GApplication ID calculation
    
    In get_gapplication_id_from_id() we sometimes make the GApp ID
    "org.gnome.Epiphany.WebApp-<checksum>". This is then used as the profile
    directory name. The profile directory is then used to calculate the id
    in ephy_web_application_setup_from_profile_directory(). But in
    get_app_id_from_gapplication_id() we return whatever's after the
    "WebApp-" prefix, since there's no way to recover the "normalized name"
    part of the ID. So, the functions that handle the ID need to work when
    it's just the checksum part without the normalized name.
    
    This is all very confusing and we should probably find a way to make it
    all simpler some day :/

 lib/ephy-web-app-utils.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index dd2291833..d75d6d03d 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -125,10 +125,11 @@ get_gapplication_id_from_id (const char *id)
   /* Split ID into: <normalized-name>-<checksum> */
   final_hyphen = strrchr (id, '-');
   if (!final_hyphen) {
-    g_warning ("Web app ID %s is broken: must contain a hyphen", id);
-    return NULL;
+    /* The id was derived from the profile dir and it's only the checksum part */
+    checksum = id;
+  } else {
+    checksum = final_hyphen + 1;
   }
-  checksum = final_hyphen + 1;
 
   if (*checksum == '\0') {
     g_warning ("Web app ID %s is broken: should end with checksum, not hyphen", id);


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