From 0ae78c829dfc7fdf6a88236846bd421ef379f3f3 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 11 Mar 2008 15:43:25 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20521591=20=E2=80=93=20g=5Fmarkup=5Fparse?= =?UTF-8?q?=5Fcontext=5Fparse()=20creates=20GError=20message=20that?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-03-11 Murray Cumming Bug 521591 – g_markup_parse_context_parse() creates GError message that is invalid UTF8. * glib/gmarkup.c (set_error): Make sure that the GError::message is valid UTF-8 even if it is complaining about invalid UTF-8 in the markup text, using _g_utf8_make_valid(). svn path=/trunk/; revision=6680 --- ChangeLog | 9 +++++++++ glib/gmarkup.c | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 05b1464d6..61b0ecada 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-03-11 Murray Cumming + + Bug 521591 – g_markup_parse_context_parse() creates GError message that + is invalid UTF8. + + * glib/gmarkup.c (set_error): Make sure that the GError::message is + valid UTF-8 even if it is complaining about invalid UTF-8 in the + markup text, using _g_utf8_make_valid(). + 2008-03-10 Matthias Clasen * === Released 2.16.1 === diff --git a/glib/gmarkup.c b/glib/gmarkup.c index e1e9aa579..f3e8c1f49 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c @@ -215,14 +215,20 @@ set_error (GMarkupParseContext *context, { GError *tmp_error; gchar *s; + gchar *s_valid; va_list args; va_start (args, format); s = g_strdup_vprintf (format, args); va_end (args); - tmp_error = g_error_new_literal (G_MARKUP_ERROR, code, s); + /* Make sure that the GError message is valid UTF-8 even if it is + * complaining about invalid UTF-8 in the markup: */ + s_valid = _g_utf8_make_valid (s); + tmp_error = g_error_new_literal (G_MARKUP_ERROR, code, s_valid); + g_free (s); + g_free (s_valid); g_prefix_error (&tmp_error, _("Error on line %d char %d: "),