Bug report: file:// URIs with special characters in file name can fail

Arseniy Lartsev arseniy at alumni.chalmers.se
Sun Aug 23 16:37:12 EDT 2020


There doesn't seem to be any way to register in the bug tracker, so posting 
here.

If a file:// URI is included in a message (which is something my plugin can 
do), and pidgin is running on Linux but with neither GNOME nor KDE, 
open_file will pass file name to purple_notify_uri. If file name contained 
spaces or other special characters that are escaped for URIs into the %XX 
notation, this will fail because handler for notify_uri does escape them. 
As such, open_file with filename like "/path/to/file name.txt" will run 
something like xdg-open /path/to/file%20name.txt, which fails.

Attaching a patch that fixes this by prepending file:// back before passing 
file name to purple_notify_uri.

# HG changeset patch
# User Arseniy Lartsev <arseniy at alumni.chalmers.se>
# Date 1598214244 -7200
#      Sun Aug 23 22:24:04 2020 +0200
# Branch release-2.x.y
# Node ID c2d8b8e6538cd98498cc45ff3c73af760ab2894f
# Parent  2320cf8d228a30c2e6687e36029f6d03392ce9f0
pidgin: fixed opening file:// URLs with special characters

When running on Linux with neither GNOME nor KDE, file:// hyperlinks
were opened by passing file path to purple_notify_uri. This failed if
file names contained spaces or other special characters which URI
handler will escape before passing to xdg-open or whatever.

Prepend file:// before passing file name to purple_notify_uri.

diff -r 2320cf8d228a -r c2d8b8e6538c pidgin/gtkutils.c
--- a/pidgin/gtkutils.c Mon Jul 27 00:21:25 2020 -0500
+++ b/pidgin/gtkutils.c Sun Aug 23 22:24:04 2020 +0200
@@ -3309,7 +3309,10 @@
        }
        else
        {
-               purple_notify_uri(NULL, filename);
+               gchar *uri = g_strconcat("file://", filename, NULL);
+               fprintf(stderr, "purple_notify_uri '%s'\n", uri);
+               purple_notify_uri(NULL, uri);
+               g_free(uri);
                return;
        }
 


More information about the Support mailing list