https://bugs.winehq.org/show_bug.cgi?id=57329
Bug ID: 57329 Summary: Desktop files generated by Wine do not conform to the Desktop Entry Specification Product: Wine Version: 9.20 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: meator.dev@gmail.com Distribution: ---
Desktop files generated by Wine do not conform to the latest (and older) version to of the Desktop Entry Specification, primarily the Exec key specification: https://specifications.freedesktop.org/desktop-entry-spec/1.5/exec-variables...
For example, this is how the desktop file for Notepad++ looks like (located at /home/meator/.local/share/applications/wine/Programs/Notepad++.desktop):
[Desktop Entry] Name=Notepad++ Exec=env WINEPREFIX="/home/meator/.wine" wine C:\\ProgramData\\Microsoft\\Windows\\Start\ Menu\\Programs\\Notepad++.lnk Type=Application StartupNotify=true Path=/home/meator/.wine/dosdevices/c:/Program Files/Notepad++ Icon=7ABC_notepad++.0 StartupWMClass=notepad++.exe
I will ignore the `env WINEPREFIX="/home/meator/.wine"` part of Exec now.
The Exec key parsing is done in two rounds (that's why there are so many backslashes). The first round is common to all keys of type string, localestring and iconstring (which includes the Exec key). The standard mandates:
The escape sequences \s, \n, \t, \r, and \ are supported for values of type string, localestring and iconstring, meaning ASCII space, newline, tab, carriage return, and backslash, respectively.
This is how the command line looks after undoing the first layer of escapes:
wine C:\users\meator\AppData\Roaming\Microsoft\Windows\Start\ Menu\Programs\Microsoft\ Office\ PowerPoint\ Viewer\ 2003.lnk
Then the Exec quoting continues. The standard mandates:
Quoting must be done by enclosing the argument between double quotes and escaping the double quote character, backtick character ("`"), dollar sign ("$") and backslash character ("") by preceding it with an additional backslash character. Implementations must undo quoting before expanding field codes and before passing the argument to the executable program. Reserved characters are space (" "), tab, newline, double quote, single quote ("'"), backslash character (""), greater-than sign (">"), less-than sign ("<"), tilde ("~"), vertical bar ("|"), ampersand ("&"), semicolon (";"), dollar sign ("$"), asterisk ("*"), question mark ("?"), hash mark ("#"), parenthesis ("(") and (")") and backtick character ("`").
The first problem is that the second argument is not enclosed in double quotes, so all escapes in it are unspecified. The second problem is that `\ ` space escape is used, which is not specified (this is the most severe problem). It is specified as a "reserved character", but not as a character requiring a backslash escape. Because of these issues, fully conformant desktop file parsers will fail to parse desktop files generated by Wine.
This is how a fixed Notepad++ desktop file looks like:
[Desktop Entry] Name=Notepad++ Exec=env "WINEPREFIX=/home/meator/.wine" wine "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Notepad++.lnk" Type=Application StartupNotify=true Path=/home/meator/.wine/dosdevices/c:/Program Files/Notepad++ Icon=7ABC_notepad++.0 StartupWMClass=notepad++.exe
I have also quoted `WINEPREFIX=/home/meator/.wine` in whole, because the entire argument should be quoted according to the standard (but I consider this issue to be less important).
System info ===========
OS: Void Linux Wine version: wine-9.20 (downloaded through package manager) Notepad++ download: https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8....