[gnome-software] snap: Remove Windows line endings from the description text
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] snap: Remove Windows line endings from the description text
- Date: Thu, 14 Sep 2017 11:39:13 +0000 (UTC)
commit 2f2a5334cd8e8dcb0c1eb8f7160d64335db233c3
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 14 12:38:27 2017 +0100
snap: Remove Windows line endings from the description text
If this is left then the GsAppRow does not truncate the text correctly.
Remove when https://forum.snapcraft.io/t/snap-metadata-newline-characters/2116
is fixed.
plugins/snap/gs-plugin-snap.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 6e2e259..231b7f9 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -597,6 +597,15 @@ find_launch_app (GsApp *app, SnapdSnap *local_snap)
gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
}
+static gchar *
+gs_plugin_snap_get_description_safe (SnapdSnap *snap)
+{
+ GString *str = g_string_new (snapd_snap_get_description (snap));
+ as_utils_string_replace (str, "\r", "");
+ as_utils_string_replace (str, " ", " ");
+ return g_string_free (str, FALSE);
+}
+
gboolean
gs_plugin_refine_app (GsPlugin *plugin,
GsApp *app,
@@ -621,6 +630,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
local_snap = snapd_client_list_one_sync (priv->client, id, cancellable, NULL);
if (local_snap != NULL) {
const gchar *name;
+ g_autofree gchar *description = NULL;
if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
name = snapd_snap_get_title (local_snap);
@@ -628,7 +638,9 @@ gs_plugin_refine_app (GsPlugin *plugin,
name = snapd_snap_get_name (local_snap);
gs_app_set_name (app, GS_APP_QUALITY_NORMAL, name);
gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_summary (local_snap));
- gs_app_set_description (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_description (local_snap));
+ description = gs_plugin_snap_get_description_safe (local_snap);
+ if (description != NULL)
+ gs_app_set_description (app, GS_APP_QUALITY_NORMAL, description);
gs_app_set_license (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_license (local_snap));
gs_app_set_version (app, snapd_snap_get_version (local_snap));
gs_app_set_size_installed (app, snapd_snap_get_installed_size (local_snap));
@@ -646,6 +658,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
if (store_snap != NULL) {
GPtrArray *screenshots;
const gchar *name;
+ g_autofree gchar *description = NULL;
if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
@@ -655,7 +668,9 @@ gs_plugin_refine_app (GsPlugin *plugin,
name = snapd_snap_get_name (store_snap);
gs_app_set_name (app, GS_APP_QUALITY_NORMAL, name);
gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_summary (store_snap));
- gs_app_set_description (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_description (store_snap));
+ description = gs_plugin_snap_get_description_safe (store_snap);
+ if (description != NULL)
+ gs_app_set_description (app, GS_APP_QUALITY_NORMAL, description);
gs_app_set_license (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_license (store_snap));
gs_app_set_version (app, snapd_snap_get_version (store_snap));
gs_app_set_size_download (app, snapd_snap_get_download_size (store_snap));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]