Skip to content

DesktopEntryParser does not process escaped spaces in Exec correctly #1596

@jmholla

Description

@jmholla

Source

Open Build Service

App logs

These are the relevant logs. There's a lot of noise and identifying information in the rest of the logs. I've also replaced my home directory with `~`:


13:58:49 [info:albert] Activating action applications > factorio-space-age-2 > launch (Applications > Temp Factorio: Space Age > Launch application)
13:58:49 [debg:albert] Storing activation…
13:58:49 [debg:albert] Fetching usage scores…
13:58:49 [warn:albert] Starting detached process failed. QList(~/games/Factorio:\, Space, Age/factorio/bin/x64/factorio)

Current Behavior

The application fails to launch because the desktop file parser treats \\ as an escaped slash plus an argument separator. But, the desktop file specification seems to indicate that this is the proper way to escape a slash:

Note that the general escape rule for values of type string states that the backslash character can be escaped as ("\") as well and that this escape rule is applied before the quoting rule. As such, to unambiguously represent a literal backslash character in a quoted argument in a desktop entry file requires the use of four successive backslash characters ("\\"). Likewise, a literal dollar sign in a quoted argument in a desktop entry file is unambiguously represented with ("\$").

Interestingly, it looks like the escaping done by Albert works differently on the first escaped space and the second. Looking at the logs, while they are passed as separate arguments, the second escaping does not include the escaped backslash.

Below is my desktop file (with my home directory replaced):

[Desktop Entry]
Name=Temp Factorio: Space Age
Exec=~/games/Factorio:\\ Space Age/factorio/bin/x64/factorio
Comment=Mine, research, build, automate, fight, and fly.
Terminal=false
PrefersNonDefaultGPU=false
Icon=/home/joshua/games/Factorio: Space Age/factorio/data/base/thumbnail.png
Type=Application
Categories=Game;

This results in the following word parsing in the logs:

~/games/Factorio:\
Space
Age/factorio/bin/x64/factorio

Note that Space does not have a trailing backslash. Just wanted to point that out as an extra level of peculiarity I noticed.

Expected Behavior

The parsers should escape the backslash then use that to escape the space. This would make the application launchable.

Quoting the executable does work, and is the workaround I've been using.

Exec="~/games/Factorio: Space Age/factorio/bin/x64/factorio"

Anything else?

I filed a report against the applications plugin, but once I started looking into the code, I saw that it was calling into the library provided by Albert.

Metadata

Metadata

Labels

Needs triagePriority has not been evaluated yet.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions