A few questions about escaping in desktop files
meator <[email protected]> Mon, 22 Aug 2022 09:41:45 +0200
| Newsgroups | gmane.linux.xdg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello. I'm reading the latest Desktop Entry Specification and I have some questions. If I understand it correctly, there are three phases of parsing a Exec key: the base escaping which is done for string, localestring, iconstring and therefore for Exec, Exec quoting and then field code expansion. I've noticed that a lot of the special characters in the second phase have something to do with the shell. Is shell supposed to be involved in the execution of the program? I'm currently executing it directly (I'm not doing sh -c <args>). If there isn't a shell involved, why are there so many restricted characters? They look pretty useless. The rule says that the argument containing one or more restricted characters shall be enclosed in double quotes and the characters matching regex ["`$\\] shall be escaped with \. So when I have Exec=true $test > 1 It should be quoted as Exec=true "\\$test" ">" 1 And the program would receive three arguments (argc = 4), "$test", ">" and "1" or JHRlc3Q=, Pg==, MQ== in base64 (I'm including the base64 encoded string because it is unambiguous). Is this correct? > Arguments are separated by a space. A literal space ' ' 0x20? For example the shell uses $IFS which allows a space, a tab and a newline as separators. So Exec=true a\nb would mean that the 'true' program would receive a single argument (i.e. argc = 2). The "\n" would be replaced with a newline in the first phase of parsing and the program would receive "a<newline>b" as the first argument or YQpi in base64. Is this correct? Let's say I would like to pass a literal "\n" (XG4=) to the program. Exec=echo \\\\n Is this correct? > Arguments may be quoted in whole. What does this mean? How many arguments of echo would Exec=echo prefix%isuffix produce? 2 or 4? Thanks in advance, meator
OpenPGP_signature
(application/pgp-signature, 659 B) - not displayed