This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit 72c82e49814ba62c99bac2f06ba83747befc2b0a
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Fri Jun 20 19:56:23 2025 +0100

    resolve vars in open backend for desktop files
---
 src/backends/default/open.c | 65 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 2 deletions(-)

diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index 393a15a..27531e5 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -18,6 +18,7 @@
 #include <grp.h>
 
 #include "cmd.h"
+#include "eina_strbuf.h"
 #include "eina_types.h"
 #include "sha.h"
 #include "meta.h"
@@ -686,6 +687,55 @@ _file_add_mod_meta_append(const char *path, const char *meta, const char *key,
   eina_stringshare_del(s);
 }
 
+static char *
+_env_var_resolve(const char *str)
+{
+  Eina_Strbuf *buf = eina_strbuf_new();
+  char        *s, *e, *tmp, save, *env = NULL, *strout = NULL;
+
+  if (!buf) return NULL;
+  tmp = strdup(str);
+  if (!tmp) goto err;
+  for (s = tmp; *s; s++)
+    {
+      if (!env)
+        {
+          if (*s == '$')
+            { // found start of an env var - 0 the $ and mark beginning
+              *s = 0;
+              env = s + 1;
+            }
+          else eina_strbuf_append_char(buf, *s);
+        }
+      else
+        {
+          if (!(((*s >= 'a') && (*s <= 'z')) || ((*s >= 'A') && (*s <= 'Z'))
+                || ((*s >= '0') && (*s <= '9')) || (*s == '_')))
+            { //  char is not a valid env var char (a-z, A-Z, _)
+              save = *s;
+              *s = 0;
+              e    = getenv(env);
+              if (e) eina_strbuf_append(buf, e);
+              eina_strbuf_append_char(buf, save);
+              env = NULL;
+            }
+        }
+    }
+  // handle $ENV at end
+  if (env)
+    {
+      e = getenv(env);
+      if (e) eina_strbuf_append(buf, e);
+    }
+
+  strout = eina_strbuf_string_steal(buf);
+err:
+  free(tmp);
+  eina_strbuf_free(buf);
+  return strout;
+}
+
+
 static void
 _file_add_mod_desktop_fields_append(Eina_Strbuf *strbuf, Efreet_Desktop *d,
                                     const char *key_prefix, const char *path,
@@ -693,7 +743,7 @@ _file_add_mod_desktop_fields_append(Eina_Strbuf *strbuf, Efreet_Desktop *d,
 {
   Eina_Strbuf *keybuf = eina_strbuf_new();
   char        *icf;
-  const char  *icon;
+  const char  *icon, *s;
 
   if (!keybuf) return;
 #define KEY(_x)                                             \
@@ -750,7 +800,18 @@ _file_add_mod_desktop_fields_append(Eina_Strbuf *strbuf, Efreet_Desktop *d,
   KEY("desktop-exec");
   cmd_strbuf_append(strbuf, KEYSTR(), STREMPTY(d->exec));
   KEY("desktop-url");
-  cmd_strbuf_append(strbuf, KEYSTR(), STREMPTY(d->url));
+  s = _desktop_x_field(d, "X-Enlightenment-Type");
+  if ((d->url) && (s) && (!strcmp(s, "Mount")))
+    { // XXX:  resolve $ENV $VAR etc if X-Enlightenment-Type == Mount
+      char *res = _env_var_resolve(d->url);
+
+      if (res)
+        {
+          cmd_strbuf_append(strbuf, KEYSTR(), res);
+          free(res);
+        }
+    }
+  else cmd_strbuf_append(strbuf, KEYSTR(), STREMPTY(d->url));
   KEY("desktop-no-display");
   cmd_strbuf_append(strbuf, KEYSTR(), STRBOOL(d->no_display));
   KEY("desktop-hidden");

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to