From a550bac7a423943b79b98c322d665cef6f16e759 Mon Sep 17 00:00:00 2001 From: kajzer Date: Fri, 9 Sep 2016 18:35:48 +0200 Subject: Fix: properly escape text --- src/themes/coco/coco-theme.c | 14 ++++++++++---- src/themes/nodoka/nodoka-theme.c | 14 ++++++++++---- src/themes/slider/theme.c | 13 ++++++++++--- src/themes/standard/theme.c | 13 ++++++++++--- 4 files changed, 40 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/themes/coco/coco-theme.c b/src/themes/coco/coco-theme.c index ca742b4..c1fa929 100644 --- a/src/themes/coco/coco-theme.c +++ b/src/themes/coco/coco-theme.c @@ -506,10 +506,16 @@ set_notification_text(GtkWindow *nw, const char *summary, const char *body) gtk_label_set_markup(GTK_LABEL(windata->summary_label), str); g_free(str); - quoted = g_markup_escape_text(body, -1); - str = g_strdup_printf( - "%s", quoted); - g_free(quoted); + if (strstr(body, "&") || strstr(body, "<") || strstr(body, ">") || strstr(body, "'") || strstr(body, """)) + { + str = g_strdup_printf("%s", body); + } + else + { + quoted = g_markup_escape_text(body, -1); + str = g_strdup_printf("%s", quoted); + g_free(quoted); + } gtk_label_set_markup (GTK_LABEL (windata->body_label), str); g_free(str); diff --git a/src/themes/nodoka/nodoka-theme.c b/src/themes/nodoka/nodoka-theme.c index 628a415..dcb8449 100644 --- a/src/themes/nodoka/nodoka-theme.c +++ b/src/themes/nodoka/nodoka-theme.c @@ -891,10 +891,16 @@ set_notification_text(GtkWindow *nw, const char *summary, const char *body) gtk_label_set_markup(GTK_LABEL(windata->summary_label), str); g_free(str); - quoted = g_markup_escape_text(body, -1); - str = g_strdup_printf( - "%s", quoted); - g_free(quoted); + if (strstr(body, "&") || strstr(body, "<") || strstr(body, ">") || strstr(body, "'") || strstr(body, """)) + { + str = g_strdup_printf("%s", body); + } + else + { + quoted = g_markup_escape_text(body, -1); + str = g_strdup_printf("%s", quoted); + g_free(quoted); + } gtk_label_set_markup(GTK_LABEL(windata->body_label), str); g_free(str); diff --git a/src/themes/slider/theme.c b/src/themes/slider/theme.c index 86440b0..cf4724a 100644 --- a/src/themes/slider/theme.c +++ b/src/themes/slider/theme.c @@ -513,9 +513,16 @@ void set_notification_text(GtkWindow* nw, const char* summary, const char* body) gtk_label_set_markup(GTK_LABEL(windata->summary_label), str); g_free(str); - quoted = g_markup_escape_text(body, -1); - gtk_label_set_markup(GTK_LABEL(windata->body_label), quoted); - g_free(quoted); + if (strstr(body, "&") || strstr(body, "<") || strstr(body, ">") || strstr(body, "'") || strstr(body, """)) + { + gtk_label_set_markup(GTK_LABEL(windata->body_label), body); + } + else + { + quoted = g_markup_escape_text(body, -1); + gtk_label_set_markup(GTK_LABEL(windata->body_label), quoted); + g_free(quoted); + } if (body == NULL || *body == '\0') { diff --git a/src/themes/standard/theme.c b/src/themes/standard/theme.c index ba44fcd..f13d174 100644 --- a/src/themes/standard/theme.c +++ b/src/themes/standard/theme.c @@ -857,9 +857,16 @@ void set_notification_text(GtkWindow* nw, const char* summary, const char* body) gtk_label_set_markup(GTK_LABEL(windata->summary_label), str); g_free(str); - quoted = g_markup_escape_text(body, -1); - gtk_label_set_markup(GTK_LABEL(windata->body_label), quoted); - g_free(quoted); + if (strstr(body, "&") || strstr(body, "<") || strstr(body, ">") || strstr(body, "'") || strstr(body, """)) + { + gtk_label_set_markup(GTK_LABEL(windata->body_label), body); + } + else + { + quoted = g_markup_escape_text(body, -1); + gtk_label_set_markup(GTK_LABEL(windata->body_label), quoted); + g_free(quoted); + } if (body == NULL || *body == '\0') { -- cgit v1.2.1