diff libpurple/util.h @ 27019:bf9db4c67679

Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages. We will no longer send messages which contain entities considered invalid in XML 1.0 (i.e.  and other ASCII control characters). Closes #5768.
author Paul Aurich <paul@darkrain42.org>
date Wed, 03 Jun 2009 19:09:16 +0000
parents af4a4ebc6441
children 6bd7b3e06233
line wrap: on
line diff
--- a/libpurple/util.h	Wed Jun 03 17:09:18 2009 +0000
+++ b/libpurple/util.h	Wed Jun 03 19:09:16 2009 +0000
@@ -1248,6 +1248,21 @@
 gchar *purple_utf8_salvage(const char *str);
 
 /**
+ * Removes unprintable characters from a UTF-8 string. These characters
+ * (in particular low-ASCII characters) are invalid in XML 1.0 and thus
+ * are not allowed in XMPP and are rejected by libxml2 by default. This
+ * function uses g_unichar_isprint to determine what characters should
+ * be stripped. The returned string must be freed by the caller.
+ *
+ * @param str A valid UTF-8 string.
+ *
+ * @return A newly allocated UTF-8 string without the unprintable characters.
+ *
+ * @see g_unichar_isprint
+ */
+gchar *purple_utf8_strip_unprintables(const gchar *str);
+
+/**
  * Return the UTF-8 version of gai_strerror().  It calls gai_strerror()
  * then converts the result to UTF-8.  This function is analogous to
  * g_strerror().