gnome-software/0002-gs-appstream-Fix-handling-of-icons-where-appdata-doe.patch

49 lines
1.6 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 9a63168893a678f97fe6e3bfde2d6e5debf151c3 Mon Sep 17 00:00:00 2001
From: Philip Withnall <pwithnall@endlessos.org>
Date: Tue, 16 Mar 2021 13:34:13 +0000
Subject: [PATCH 2/4] =?UTF-8?q?gs-appstream:=20Fix=20handling=20of=20icons?=
=?UTF-8?q?=20where=20appdata=20doesn=E2=80=99t=20specify=20width?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If the `<icon>` element in the appdata doesnt specify a `width`
attribute, `xb_node_get_attr_as_uint()` will return `G_MAXUINT64`.
However, its return value was being assigned to `sz`, which is a
`guint`, and hence it was being truncated. This resulted in icons having
their widths set to `G_MAXUINT`, and hence being prioritised for display
when that was not necessarily correct.
Fix that by explicitly handling the failure response from
`xb_node_get_attr_as_uint()`.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #1171
---
plugins/core/gs-appstream.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index a9cf97270..22fed1154 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -149,8 +149,12 @@ gs_appstream_new_icon (XbNode *component, XbNode *n, AsIconKind icon_kind, guint
default:
as_icon_set_name (icon, xb_node_get_text (n));
}
- if (sz == 0)
- sz = xb_node_get_attr_as_uint (n, "width");
+ if (sz == 0) {
+ guint64 width = xb_node_get_attr_as_uint (n, "width");
+ if (width > 0 && width < G_MAXUINT)
+ sz = width;
+ }
+
if (sz > 0) {
as_icon_set_width (icon, sz);
as_icon_set_height (icon, sz);
--
2.30.2