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

git pushed a commit to branch fix/file-url-percent-decode
in repository terminology.

View the commit online.

commit 859da291bc5f607fa3cd7e61ee0a80746becd36f
Author: Cedric BAIL <[email protected]>
AuthorDate: Thu Apr 30 13:23:43 2026 -0600

    termio: percent-decode file:// URLs before opening
    
    Closes a long-standing TODO at termio.c:710. file:// URIs with
    percent-encoded characters (e.g., spaces as %20) were passed
    verbatim to the file-opening logic, causing the handler to look
    for files literally named with %20 in their filenames.
    
    Add _percent_decode_inplace following RFC 3986 §2.1, called right
    after the file:// prefix is stripped. Malformed sequences pass
    through unchanged (no crash on incomplete or non-hex %XX).
    
    Example:
      Before: file:///home/u/My%20Docs → opens '/home/u/My%20Docs'
      After:  file:///home/u/My%20Docs → opens '/home/u/My Docs'
---
 src/bin/termio.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index baad9d0d..4629dde8 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -660,6 +660,46 @@ termio_set_cursor_shape(Evas_Object *obj, Cursor_Shape shape)
 /* }}} */
 /* {{{ Links */
 
+/* Percent-decode a URI string in-place. Decodes %XX sequences to
+ * their byte value. Malformed sequences (incomplete or non-hex)
+ * pass through unchanged.
+ *
+ * Per RFC 3986 §2.1. Used to convert file:// URIs to plain paths. */
+static void
+_percent_decode_inplace(char *s)
+{
+   char *r;  /* read cursor */
+   char *w;  /* write cursor */
+
+   if (!s) return;
+
+   for (r = w = s; *r; )
+     {
+        if (r[0] == '%' && r[1] && r[2])
+          {
+             int hi = -1, lo = -1;
+             char c1 = r[1], c2 = r[2];
+
+             if      (c1 >= '0' && c1 <= '9') hi = c1 - '0';
+             else if (c1 >= 'A' && c1 <= 'F') hi = c1 - 'A' + 10;
+             else if (c1 >= 'a' && c1 <= 'f') hi = c1 - 'a' + 10;
+
+             if      (c2 >= '0' && c2 <= '9') lo = c2 - '0';
+             else if (c2 >= 'A' && c2 <= 'F') lo = c2 - 'A' + 10;
+             else if (c2 >= 'a' && c2 <= 'f') lo = c2 - 'a' + 10;
+
+             if (hi >= 0 && lo >= 0)
+               {
+                  *w++ = (char)((hi << 4) | lo);
+                  r += 3;
+                  continue;
+               }
+          }
+        *w++ = *r++;
+     }
+   *w = '\0';
+}
+
 static Eina_Bool
 _should_inline(const Evas_Object *obj)
 {
@@ -707,7 +747,7 @@ termio_link_get(const Evas_Object *obj,
      {
         if (casestartswith(link, "file://"))
           {
-             // TODO: decode string: %XX -> char
+             char *decoded;
              link = link + sizeof("file://") - 1;
              /* Handle cases where / is omitted: file://HOSTNAME/home/ */
              if (link[0] != '/')
@@ -716,6 +756,11 @@ termio_link_get(const Evas_Object *obj,
                   if (!link)
                     return NULL;
                }
+             /* Percent-decode the path per RFC 3986 §2.1
+              * (e.g., file:///home/u/My%20Docs → /home/u/My Docs) */
+             decoded = strdup(link);
+             if (decoded) _percent_decode_inplace(decoded);
+             return decoded;
           }
      }
    return strdup(link);

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

Reply via email to