Fix handling of desktop files with multiple groups (#1086122)

This commit is contained in:
Till Maas 2014-04-11 18:39:09 +02:00
parent 56ee6ad099
commit 657fc75d5e
2 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,59 @@
From 04eda04f2068f709b4a599ec8a06643d4f80565d Mon Sep 17 00:00:00 2001
From: Till Maas <opensource@till.name>
Date: Fri, 11 Apr 2014 18:35:34 +0200
Subject: [PATCH 10/10] xdg-open: Support multiple groups
Desktop files might contain multiple groups. Check for keys only in the
Desktop Entry group.
---
scripts/xdg-open.in | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in
index e7a15a9..b994fa5 100644
--- a/scripts/xdg-open.in
+++ b/scripts/xdg-open.in
@@ -36,15 +36,36 @@ last_word()
echo "$rest"
}
-# Get the value of a key in a .desktop file.
+# Get the value of a key in a desktop file's Desktop Entry group.
# Example: Use get_key foo.desktop Exec
-# to get the values of the Exec= key
+# to get the values of the Exec= key for the Desktop Entry group.
get_key()
{
local file="${1}"
local key="${2}"
-
- grep -E "^${key}=" "${file}" | cut -d= -f 2-
+ local desktop_entry=""
+
+ IFS_="${IFS}"
+ IFS=""
+ while read line
+ do
+ case "$line" in
+ "[Desktop Entry]")
+ desktop_entry="y"
+ ;;
+ # Reset match flag for other groups
+ [*)
+ desktop_entry=""
+ ;;
+ *)
+ # Only match Desktop Entry group
+ if [ -n "${desktop_entry}" ]
+ then
+ echo "${line}" | grep -E "^${key}=" "${file}" | cut -d= -f 2-
+ fi
+ esac
+ done < "${file}"
+ IFS="${IFS_}"
}
open_darwin()
--
1.8.3.1

View File

@ -4,7 +4,7 @@
Summary: Basic desktop integration functions Summary: Basic desktop integration functions
Name: xdg-utils Name: xdg-utils
Version: 1.1.0 Version: 1.1.0
Release: 0.22.%{pre}%{?dist} Release: 0.23.%{pre}%{?dist}
URL: http://portland.freedesktop.org/ URL: http://portland.freedesktop.org/
%if 0%{?pre:1} %if 0%{?pre:1}
@ -26,6 +26,7 @@ Patch106: 0006-all-re-generate-html-man-too.patch
Patch107: 0007-drop-references-to-Value-1.0-key-BR74688.patch Patch107: 0007-drop-references-to-Value-1.0-key-BR74688.patch
Patch108: 0008-xdg-open-Remove-first_word-already-in-common.patch Patch108: 0008-xdg-open-Remove-first_word-already-in-common.patch
Patch109: 0009-xdg-open-Expand-i-and-c-from-Exec.patch Patch109: 0009-xdg-open-Expand-i-and-c-from-Exec.patch
Patch110: 0010-xdg-open-Support-multiple-groups.patch
BuildRequires: gawk BuildRequires: gawk
BuildRequires: xmlto text-www-browser BuildRequires: xmlto text-www-browser
@ -69,6 +70,7 @@ The following scripts are provided at this time:
%patch107 -p1 -b .0007 %patch107 -p1 -b .0007
%patch108 -p1 -b .0008 %patch108 -p1 -b .0008
%patch109 -p1 -b .0009 %patch109 -p1 -b .0009
%patch110 -p1 -b .0010
%build %build
@ -106,6 +108,9 @@ make install DESTDIR=%{buildroot}
%changelog %changelog
* Fri Apr 11 2014 Till Maas <opensource@till.name> - 1.1.0-0.23.rc2
- Fix handling of desktop files with multiple groups (#1086122)
* Fri Apr 04 2014 Rex Dieter <rdieter@fedoraproject.org> 1.1.0-0.22.rc2 * Fri Apr 04 2014 Rex Dieter <rdieter@fedoraproject.org> 1.1.0-0.22.rc2
- drop using %%autosetup (it didn't work?) - drop using %%autosetup (it didn't work?)