refi64 / flextop

GNU General Public License v2.0
4 stars 2 forks source link

Quoting flatpak in Exec= line defeats special handling in GDesktopFileInfo #2

Closed wjt closed 3 years ago

wjt commented 3 years ago

GLib contains a function to search installed desktop files for a given set of search terms. The implementation includes the binary name from the Exec= key in the index. To avoid a search for 'flatpak' (and a number of common interpreters) matching every app on the system, there is special logic to ignore the binary name if is one of these common interpreters.

However, the implementation in GLib currently performs a simple split at the first whitespace character then checks for exact string equality. flextop quotes each parameter in the rewritten Exec= line, including the leading flatpak command:

https://github.com/refi64/flextop/blob/b8ca6d9952a9f5d40df99903448c3fa7ccea80ee/src/xdg-desktop-menu.c#L75-L78

Here is the resulting line from a launcher I have just created:

Exec='flatpak' 'run' '--branch=beta' '--arch=x86_64' '--command=/app/bin/chromium' 'org.chromium.Chromium' '--profile-directory=Default' '--app-id=hnpfjngllnobngcgfapefoaidbinmjnm'

As a result, a desktop search for "Flatpak" matches this launcher. (I'd attach a screenshot but the file chooser portal has apparently fallen down a well.)

One might argue that GLib should parse the line with g_shell_parse_argv() rather than string-splitting. But Flextop could avoid this issue by only quoting the strings that may need to be quoted (namely the ones parsed out of the original Exec= line) rather than the statically-known ones like flatpak and run.