summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-02-02 09:38:18 (GMT)
committerRichard Hughes <richard@hughsie.com>2016-02-02 09:38:20 (GMT)
commitec41a3671850df63dabe04f197f638956af2ddba (patch)
tree2bfc588157d120944bbfd703fd9570f95d7646eb
parentc228a71160539859bf908599fa294b83c2856350 (diff)
downloadgnome-software-ec41a3671850df63dabe04f197f638956af2ddba.zip
gnome-software-ec41a3671850df63dabe04f197f638956af2ddba.tar.xz
Use a hashed URL prefix for the screenshot local cache filename
For metadata that has not been run with 'appstream-util mirror-screenshots' all it takes is for one upstream to choose the same basename for the URL as another application before there is a clash, for instance 'Screenshot1.png'. This scheme should also stop evil apps showing the wrong screenshot for other applications. Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=761434
-rw-r--r--src/gs-screenshot-image.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 7f9c8a9..7c015b1 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -336,6 +336,19 @@ gs_screenshot_image_set_use_desktop_background (GsScreenshotImage *ssimg,
}
/**
+ * gs_screenshot_get_cachefn_for_url:
+ **/
+static gchar *
+gs_screenshot_get_cachefn_for_url (const gchar *url)
+{
+ g_autofree gchar *basename = NULL;
+ g_autofree gchar *checksum = NULL;
+ checksum = g_compute_checksum_for_string (G_CHECKSUM_SHA256, url, -1);
+ basename = g_path_get_basename (url);
+ return g_strdup_printf ("%s-%s", checksum, basename);
+}
+
+/**
* gs_screenshot_image_load_async:
**/
void
@@ -377,7 +390,7 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
return;
}
url = as_image_get_url (im);
- basename = g_path_get_basename (url);
+ basename = gs_screenshot_get_cachefn_for_url (url);
if (ssimg->width == G_MAXUINT || ssimg->height == G_MAXUINT) {
sizedir = g_strdup ("unknown");
} else {