Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the File-DesktopEntry CPAN distribution.

Report information
The Basics
Id: 93168
Status: resolved
Priority: 0/
Queue: File-DesktopEntry

People
Owner: Nobody in particular
Requestors: zero.lutin [...] yahoo.fr
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.20



Subject: Paths are not escaped when converted to URIs.
Date: Wed, 19 Feb 2014 21:47:08 +0100
To: bug-File-DesktopEntry [...] rt.cpan.org
From: Lutin <zero.lutin [...] yahoo.fr>
My configuration: ----------------- - perl version 5.14.2 - File::DesktopEntry version 0.08 The problem: ------------ Opening a file containing non standard characters with the program mimeopen will fail in some applications. For example, the shell command : $ mimeopen '/home/lutin/#.html' will open the url 'file:///home/lutin/#.html' in firefox, which results in firefox showing me the '/home/lutin' directory listing. (even though '#.html' is a valid html file). Then if I manually escape the '#' character in the urlbar (to become 'file:///home/lutin/%23.html'), firefox works as expected and shows me the page. Also, not escaped uri paths cause vlc to segfault ($ mimeopen '#.mp4', for instance). This problem is caused by paths being not escaped when tranformed to uri in File::DesktopEntry module, here: 422 sub _uris { 423 # Convert paths to file:// uris 424 map { 425 m#^\w+://# ? $_ : 'file://'.File::Spec->rel2abs($_) ; 426 } @_; 427 } The proposed patch: ------------------- I propose to use a code analog to the Python 'urllib.pathname2url()' function: --- DesktopEntry.pm.orig 2014-02-19 21:26:52.242558332 +0100 +++ DesktopEntry.pm 2014-02-19 21:27:32.041268764 +0100 @@ -7,6 +7,7 @@ use Carp; use File::Spec; use File::BaseDir 0.03 qw/data_files data_home/; +use URI::Escape; our $VERSION = 0.08; our $VERBOSE = 0; @@ -422,10 +423,14 @@ sub _uris { # Convert paths to file:// uris map { - m#^\w+://# ? $_ : 'file://'.File::Spec->rel2abs($_) ; + m#^\w+://# ? $_ : 'file://'._path_to_uri(File::Spec->rel2abs($_)); } @_; } +sub _path_to_uri { + return join '/', map { uri_escape($_) } split '/', $_; +} + =item C<get(KEY)> =item C<get(GROUP, KEY)>
This is now fixed in version 0.20 on CPAN.