Skip to content

DesktopEntry::get_args (private, used in DesktopEntry::parse_exec*) does not handle quoting correctlyΒ #36

@quantenzitrone

Description

@quantenzitrone

Try this abomination desktop entry:

[Desktop Entry]
Name=Default Terminal
Type=Application
Exec=printf "|||%%s|||\\\\n" "quoting terminal" "with 'complex' arguments," "quotes \\"," "" 	"empty args," "new\nlines," "and \\"back\\\\slashes\\""
Categories=TerminalEmulator;

from Vladimir-csp/xdg-terminal-exec

parse_exec() parses this to:

[
    "printf",
    "\"|||%%s|||\\\\\\\\n\"",
    "\"quoting",
    "terminal\"",
    "\"with",
    "'complex'",
    "arguments,\"",
    "\"quotes",
    "\\\\\",\"",
    "\"\"",
    "\"empty",
    "args,\"",
    "\"new\\nlines,\"",
    "\"and",
    "\\\\\"back\\\\\\\\slashes\\\\\"\"",
]

which should be parsed to:

[
    "printf",
    "|||%s|||\\\\n",
    "quoting terminal",
    "with 'complex' arguments,",
    "quotes \\\",",
    "",
    "empty args,",
    "new\nlines",
    "and \\\"back\\\\slashes\\\"",
]

(if i unescaped and re-rust-escaped this manually correctly)

so basically what the spec says about the Exec attribute

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.
[...]
Literal percentage characters must be escaped as %%.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions