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

Bug #1517956 reported by Chad Miller
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Xdg-utils
Unknown
Medium
xdg-utils (Ubuntu)
Fix Released
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.

Tags: patch
Revision history for this message
In , Chad Miller (cmiller) wrote :

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.

Revision history for this message
In , Chad Miller (cmiller) wrote :

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
Revision history for this message
Chad Miller (cmiller) wrote : Re: xdg-settings assumes desktop files have exactly one Exec line

This is solved by "first_word" shell function.

Changed in xdg-utils (Ubuntu):
status: New → Fix Committed
Revision history for this message
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
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

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
Revision history for this message
In , Gitlab-migration (gitlab-migration) wrote :

-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/83.

Changed in xdg-utils:
status: Confirmed → Unknown
Revision history for this message
Sebastien Bacher (seb128) wrote :
Changed in xdg-utils (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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