summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2003-09-17 19:18:45 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2003-09-17 19:18:45 +0000
commit3044d0f514c3367b3439014bbdc0380ef29239a2 (patch)
tree422ca53254b1073ffc5c66841b121746e8f46e29 /gtk
parent77d23072c27501479cc0080c46d6f4bcf7d0fac0 (diff)
downloadgtk+-3044d0f514c3367b3439014bbdc0380ef29239a2.tar.gz
Report unexpected character data as error from the GMarkup parser,
2003-09-17 Matthias Clasen <maclas@gmx.de> * gtk/gtkuimanager.c (text_handler): Report unexpected character data as error from the GMarkup parser, otherwise things like gtk_ui_manager_add_ui_from_string (ui, "Hi there!", -1, &error) pass unexpectedly.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkuimanager.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c
index c36beeeb25..0cd712e8e0 100644
--- a/gtk/gtkuimanager.c
+++ b/gtk/gtkuimanager.c
@@ -1087,21 +1087,51 @@ cleanup (GMarkupParseContext *context,
gtk_ui_manager_remove_ui (ctx->self, ctx->merge_id);
}
+static gboolean
+xml_isspace (char c)
+{
+ return c == ' ' || c == '\t' || c == '\n' || c == '\r';
+}
+
+static void
+text_handler (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ const gchar *p;
+ const gchar *end;
+
+ p = text;
+ end = text + text_len;
+ while (p != end && xml_isspace (*p))
+ ++p;
+
+ if (p != end)
+ {
+ gint line_number, char_number;
+
+ g_markup_parse_context_get_position (context,
+ &line_number, &char_number);
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("Unexpected character data on line %d char %d"),
+ line_number, char_number);
+ }
+}
+
+
static GMarkupParser ui_parser = {
start_element_handler,
end_element_handler,
- NULL,
+ text_handler,
NULL,
cleanup
};
-static gboolean
-xml_isspace (char c)
-{
- return c == ' ' || c == '\t' || c == '\n' || c == '\r';
-}
-
static guint
add_ui_from_string (GtkUIManager *self,
const gchar *buffer,