xdg-open dose not search correctly in directories with spaces in the name
The problem is in search_desktop_file()
function more precisely at https://gitlab.freedesktop.org/xdg/xdg-utils/blob/master/scripts/xdg-open.in#L331
as an example to reproduce the issue try the snippet below:
reproducer()
{
local dir="$1"
for d in "$dir"/*/; do
echo "$d"
done
}
reproducer /home/valdar/.local/share/applications/Space\ Name/
you will see that the output is:
/home/valdar/.local/share/applications/Space
Name//*/
instead of:
/home/valdar/.local/share/applications/Space Name//*/
This is not only harmful because some directories are not searched, but also because it can lead to infinite loops and escape the search to directories outside the paths configured in XDG_DATA_DIRS
. As an example think about running xdg-open
from a directory with this structure:
games
|_my games
and one of the directories in your XDG_DATA_DIRS
contains a directory named not games
. You end up in an infinite loop.