Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH] desktop.eclass: Sanitize filename of desktop entry.
Date: Wed, 25 Mar 2020 08:24:32
Message-Id: ud090zvte@gentoo.org
1 make_desktop_entry() extracts the first component of the filename from
2 the Exec key in the desktop entry. This can however include arguments
3 which will end up in the filename. For example, www-client/links has
4 "Exec=links -g %u", resulting in links_-g_%u-links-2.desktop as the
5 name of the file.
6
7 The current extraction pattern originates from this CVS commit:
8 https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/eutils.eclass?r1=1.271&r2=1.272
9 with the commit message "scrub exec filename in case someone does
10 something silly like pass the fullpath to a binary".
11
12 Before that commit, anything after a space in Exec would have been
13 removed. Restore that behaviour, and in addition use only the
14 executable's basename.
15
16 While at it, get rid of the sed call and handle everything in bash.
17
18 Signed-off-by: Ulrich Müller <ulm@g.o>
19 ---
20 eclass/desktop.eclass | 6 +++---
21 1 file changed, 3 insertions(+), 3 deletions(-)
22
23 diff --git a/eclass/desktop.eclass b/eclass/desktop.eclass
24 index 6fc72ab8ec03..f310f210dfba 100644
25 --- a/eclass/desktop.eclass
26 +++ b/eclass/desktop.eclass
27 @@ -1,4 +1,4 @@
28 -# Copyright 1999-2018 Gentoo Foundation
29 +# Copyright 1999-2020 Gentoo Authors
30 # Distributed under the terms of the GNU General Public License v2
31
32 # @ECLASS: desktop.eclass
33 @@ -162,8 +162,8 @@ make_desktop_entry() {
34 else
35 local desktop_name="${PN}-${slot}"
36 fi
37 - local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop"
38 - #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop
39 + local desktop="${exec%%[[:space:]]*}"
40 + desktop="${T}/${desktop##*/}-${desktop_name}.desktop"
41
42 # Don't append another ";" when a valid category value is provided.
43 type=${type%;}${type:+;}
44 --
45 2.26.0

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies