albertlauncher / albert

A fast and flexible keyboard launcher
https://albertlauncher.github.io
Other
7.21k stars 303 forks source link

[applications] unexpected EOF while looking for matching single quote #1422

Closed stasadev closed 1 month ago

stasadev commented 1 month ago

Package source

Official and AUR 0.26.0

App logs

19:22:40 [info:albert] Detached process started successfully. (WD: /home/user, PID: 35632, CMD: QList("bash", "-ci", "'echo", "test'")
bash: cannot set terminal process group (35631): Inappropriate ioctl for device
bash: no job control in this shell
19:22:40 [debg:albert] Query deleted. [#5 '']
19:22:40 [debg:albert] Query deleted. [#6 't']
19:22:40 [debg:albert] Query deleted. [#7 'te']
19:22:40 [debg:albert] Query deleted. [#8 'tes']
19:22:40 [debg:albert] Query deleted. [#9 'test']
test': unexpected EOF while looking for matching `''

Current Behavior

Something has changed in the way Albert reads Exec with single quotes inside.

Create this desktop file, enable Applications plugin and run Test inside Albert, it doesn't work because single quotes aren't handled like before:

$ cat ~/.local/share/applications/test.desktop
[Desktop Entry]
Exec=bash -ci 'echo test'
Name=Test
Terminal=false
Type=Application

Expected Behavior

Albert 0.25.0 logs:

19:23:12 [info:albert] Detached process started successfully. PID: 36724 QList(sh, -c, bash -ci 'echo test')
19:23:12 [debg:albert] Query deleted. [#0 '']
19:23:12 [debg:albert] Query deleted. [#1 't']
19:23:12 [debg:albert] Query deleted. [#2 'te']
19:23:12 [debg:albert] Query deleted. [#3 'tes']
19:23:12 [debg:albert] Query deleted. [#4 'test']
bash: cannot set terminal process group (36723): Inappropriate ioctl for device
bash: no job control in this shell
test

Anything else?

No response

ManuelSchneid3r commented 1 month ago

Different but according to spec (hopefully). The exec key has been put into a shell until 0.25. Now the commandline is executed directly. Parsing is done as specified in the spec which states that arguments may be quoted as a whole using double quotes. So everything should work as expected. Correct me if I'm wrong.

ManuelSchneid3r commented 1 month ago

Arguments may be quoted in whole. If an argument contains a reserved character the argument must be quoted. The rules for quoting of arguments is also applicable to the executable name or path of the executable program as provided.

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 ("`").

stasadev commented 1 month ago

Okay, thank you for the explanation.

I wasn't aware of these rules, and when it says MUST, I agree with that.