diff options
author | Richard Hughes <richard@hughsie.com> | 2015-03-24 19:06:14 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-03-24 19:06:17 +0000 |
commit | 250b95f19db2df5b7143247e2d711af5bf4d17c3 (patch) | |
tree | 49c5411b95077c01666abd9d59208f65b0cd7e7b | |
parent | 87d7e3236bef6164e78ffd3e01dbbd34a72a004a (diff) | |
download | appstream-glib-250b95f19db2df5b7143247e2d711af5bf4d17c3.tar.gz |
Use the upstream screenshot when we are using appstream-builder --no-net
If we can't access the network we can't copy the screenshot onto a mirror or do
any of the resizing and padding that we normally do. This is also bad as there's
a slight privacy risk letting upstream know that the user is looking at some
specific software, and typically screenshots are not hosted on https:// so there
may be someone playing MITM games.
Also, but not resizing the screenshot we risk downloading the full size source
image just for the 112px thumbnail. But hey, it's better than nothing.
Resolves: https://github.com/hughsie/appstream-glib/issues/43
-rw-r--r-- | libappstream-builder/asb-self-test.c | 5 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-appdata.c | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c index 99104d8..5eca682 100644 --- a/libappstream-builder/asb-self-test.c +++ b/libappstream-builder/asb-self-test.c @@ -515,6 +515,11 @@ asb_test_context_test_func (AsbTestContextMode mode) "</kudos>\n" "<project_license>GPL-2.0+</project_license>\n" "<url type=\"homepage\">http://people.freedesktop.org/~hughsient/appdata/</url>\n" + "<screenshots>\n" + "<screenshot type=\"default\">\n" + "<image type=\"source\">http://people.freedesktop.org/~hughsient/appdata/long-description.png</image>\n" + "</screenshot>\n" + "</screenshots>\n" "<releases>\n" "<release version=\"1\" timestamp=\"1407844800\"/>\n" "</releases>\n" diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c index 5cf9475..56d296f 100644 --- a/libappstream-builder/plugins/asb-plugin-appdata.c +++ b/libappstream-builder/plugins/asb-plugin-appdata.c @@ -426,6 +426,16 @@ asb_plugin_process_filename (AsbPlugin *plugin, if (image == NULL) continue; + /* if no network just use the upstream location */ + if (asb_context_get_flag (plugin->ctx, + ASB_CONTEXT_FLAG_NO_NETWORK)) { + asb_package_log (asb_app_get_package (app), + ASB_PACKAGE_LOG_LEVEL_DEBUG, + "Using upstream screenshot"); + as_app_add_screenshot (AS_APP (app), ass); + continue; + } + /* load the URI or get from a cache */ tmp = as_image_get_url (image); ret = asb_plugin_appdata_load_url (plugin, |