diff --git a/wocky/wocky-xmpp-reader.c b/wocky/wocky-xmpp-reader.c index 17cbbda..6ade517 100644 --- a/wocky/wocky-xmpp-reader.c +++ b/wocky/wocky-xmpp-reader.c @@ -530,6 +530,13 @@ handle_regular_element ( const gchar *attr_value = (const gchar *) attributes[i+3]; gsize value_len = attributes[i+4] - attributes[i+3]; + if (!g_utf8_validate (attr_value, value_len, NULL)) + { + DEBUG ("NON-VALID UTF8"); + continue; + } + + if (!wocky_strdiff (attr_prefix, "xml") && !wocky_strdiff (attr_name, "lang")) { @@ -581,7 +588,7 @@ _characters (void *user_data, const xmlChar *ch, int len) WockyXmppReader *self = WOCKY_XMPP_READER (user_data); WockyXmppReaderPrivate *priv = self->priv; - if (priv->node != NULL) + if (priv->node != NULL && g_utf8_validate ((const gchar *)ch, len, NULL)) { wocky_node_append_content_n (priv->node, (const gchar *)ch, (gsize)len);