fn desktop_exec_escape(exe: &Path) -> StringExpand description
Escape a path for use inside a quoted argument of a desktop entry’s
Exec= value.
Stripping newlines is not enough (ReAgent/Codex P2 on PR #2999). All of these are legal in a Unix path and all of them change how the desktop-entry parser tokenizes the command:
"terminates the quoted argument — the rest of the path becomes separate argv entries, so the app is launched with the wrong executable.\,`,$are reserved inside quoted arguments per the Desktop Entry Specification and must be backslash-escaped.%introduces a field code (%f,%U, …); an unescaped one is substituted by the launcher. The spec’s escape for a literal is%%.- newline/CR would end the
Exec=line entirely and let the remainder be parsed as further desktop-entry keys (the original guard, kept).
Same injection class the XML path already handles via xml_escape; this
is the desktop-entry grammar’s version of it.