xdg-settings (used to) assume desktop files have exactly one Exec line

Bug #1517956 reported by Chad Miller on 2015-11-19
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Xdg-utils
Confirmed
Medium
xdg-utils (Ubuntu)
Undecided
Unassigned

Bug Description

In searching the desktop file for suitability, it scans for all lines that begin "Exec", and takes the result and packs it into a variable.

If there is exactly one Exec line, this takes out a command name to test for existence, but when more than one matches, the program name is captured as "firstexecprog\nsecondexecprog\nthirdexecprog", and "which" doesn't know how to look up a program like that and the subsequent tests fail.

Example command:

xdg-settings set default-web-browser chromium-browser.desktop

In searching the desktop file for suitability, it scans for all lines that begin "Exec", and takes the result and packs it into a variable.

If there is exactly one Exec line, this takes out a command name to test for existence, but when more than one matches, the program name is captured as "firstexecprog\nsecondexecprog\nthirdexecprog", and "which" doesn't know how to look up a program like that and the subsequent tests fail.

Output with sh's "-x" option on:

+ grep -E ^Exec(\[[^]=]*])?= /usr/share//applications/chromium-browser.desktop
+ command=chromium-browser
chromium-browser
chromium-browser
chromium-browser
+ which chromium-browser
chromium-browser
chromium-browser
chromium-browser
+ command=
+ readlink -f
+ return
+ binary=
+ [ ]
+ exit_failure_file_missing
+ [ 0 -gt 0 ]

In desktop_file_to_binary and binary_to_desktop_file functions, it makes false assumptions how many times grep may match. Those should treat each Exec match separately.

Created attachment 118501
desktopfile/binary mapping works for multi-Exec destop files

Patch against git tip to treat each matched line as a separate program.

Changed in xdg-utils:
importance: Unknown → Medium
status: Unknown → Confirmed

This is solved by "first_word" shell function.

Changed in xdg-utils (Ubuntu):
status: New → Fix Committed
Chad Miller (cmiller) wrote :

Kep this from happening again.

The old "|sed" way perserved many line. The new function call that has "|read" and echo first, only yields the first entry.

summary: - xdg-settings assumes desktop files have exactly one Exec line
+ xdg-settings (used to) assume desktop files have exactly one Exec line

The attachment "add tests." seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.