From 3312d78863435282546f031389e69b530851013a Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 27 Nov 2018 12:13:31 -0600 Subject: [PATCH] (#1471): base64-encode included SVGs to avoid mis-escaped characters We wrap SVG data from icons within another SVG with extra styling information. The wrapped SVG may contain characters that cannot be part of a data: URL (https://fetch.spec.whatwg.org/#data-urls). Librsvg 2.45 got more strict in its parsing of data: URLs; whereas previously it ignored '#' characters in them, now it considers them to be the start of a fragment identifier, which is not allowed in data: URLs anyway. To avoid unallowed characters, we now create a data: URL with a base-64 encoded SVG. Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1471 --- gtk/encodesymbolic.c | 4 ++-- gtk/gtkicontheme.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/encodesymbolic.c b/gtk/encodesymbolic.c index e6d01dd5c2..8482dffa13 100644 --- a/gtk/encodesymbolic.c +++ b/gtk/encodesymbolic.c @@ -79,7 +79,7 @@ load_symbolic_svg (char *file_data, gsize file_len, svg_height = g_strdup_printf ("%d",gdk_pixbuf_get_height (pixbuf)); g_object_unref (pixbuf); - escaped_file_data = g_markup_escape_text (file_data, file_len); + escaped_file_data = g_base64_encode ((guchar *) file_data, file_len); data = g_strconcat ("\n" "\n" - " \n" + " \n" "", NULL); g_free (escaped_file_data); diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 4de8a5c308..bc273ce59c 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -4555,7 +4555,7 @@ gtk_icon_info_load_symbolic_svg (GtkIconInfo *icon_info, width = g_strdup_printf ("%d", icon_info->symbolic_width); height = g_strdup_printf ("%d", icon_info->symbolic_height); - escaped_file_data = g_markup_escape_text (file_data, file_len); + escaped_file_data = g_base64_encode ((guchar *) file_data, file_len); g_free (file_data); g_ascii_dtostr (alphastr, G_ASCII_DTOSTR_BUF_SIZE, CLAMP (alpha, 0, 1)); @@ -4580,7 +4580,7 @@ gtk_icon_info_load_symbolic_svg (GtkIconInfo *icon_info, " fill: ", css_success, " !important;\n" " }\n" " \n" - " \n" + " \n" "", NULL); g_free (escaped_file_data);