changeset 26854:ab31daf1c1ee

Sadrul pointed me at g_markup_escape_text, thanks!
author Paul Aurich <paul@darkrain42.org>
date Sat, 02 May 2009 04:02:53 +0000
parents e72df47d41fe
children e816444c1a01
files ChangeLog.API libpurple/protocols/jabber/caps.c libpurple/util.c libpurple/util.h
diffstat 4 files changed, 5 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Sat May 02 01:26:18 2009 +0000
+++ b/ChangeLog.API	Sat May 02 04:02:53 2009 +0000
@@ -27,7 +27,6 @@
 		* purple_connection_set_protocol_data
 		* purple_contact_destroy
 		* purple_conv_chat_invite_user
-		* purple_escape_html
 		* purple_global_proxy_set_info
 		* purple_group_destroy
 		* purple_log_get_activity_score
--- a/libpurple/protocols/jabber/caps.c	Sat May 02 01:26:18 2009 +0000
+++ b/libpurple/protocols/jabber/caps.c	Sat May 02 04:02:53 2009 +0000
@@ -796,7 +796,7 @@
 static GString*
 jabber_caps_verification_append(GString *verification, const gchar *str)
 {
-	char *tmp = purple_escape_html(str);
+	char *tmp = g_markup_escape_text(str, -1);
 	verification = g_string_append(verification, tmp);
 	g_free(tmp);
 	return g_string_append_c(verification, '<');
@@ -824,10 +824,10 @@
 	/* concat identities to the verification string */
 	for (node = info->identities; node; node = node->next) {
 		JabberIdentity *id = (JabberIdentity*)node->data;
-		char *category = purple_escape_html(id->category);
-		char *type = purple_escape_html(id->type);
-		char *lang = purple_escape_html(id->lang);
-		char *name = purple_escape_html(id->name);
+		char *category = g_markup_escape_text(id->category, -1);
+		char *type = g_markup_escape_text(id->type, -1);
+		char *lang = g_markup_escape_text(id->lang, -1);
+		char *name = g_markup_escape_text(id->name, -1);
 
 		g_string_append_printf(verification, "%s/%s/%s/%s<", category,
 		        type, lang ? lang : "", name ? name : "");
--- a/libpurple/util.c	Sat May 02 01:26:18 2009 +0000
+++ b/libpurple/util.c	Sat May 02 04:02:53 2009 +0000
@@ -2357,39 +2357,6 @@
 }
 
 char *
-purple_escape_html(const char *str)
-{
-	GString *ret;
-	const char *in = str;
-
-	if (str == NULL)
-		return NULL;
-
-	ret = g_string_sized_new(strlen(str));
-	for ( ; *in; ++in) {
-		switch (*in) {
-			case '&':
-				ret = g_string_append_len(ret, "&amp;", 5);
-				break;
-			case '"':
-				ret = g_string_append_len(ret, "&quot;", 6);
-				break;
-			case '<':
-				ret = g_string_append_len(ret, "&lt;", 4);
-				break;
-			case '>':
-				ret = g_string_append_len(ret, "&gt;", 4);
-				break;
-			default:
-				ret = g_string_append_c(ret, *in);
-				break;
-		}
-	}
-
-	return g_string_free(ret, FALSE);
-}
-
-char *
 purple_unescape_html(const char *html) {
 	if (html != NULL) {
 		const char *c = html;
--- a/libpurple/util.h	Sat May 02 01:26:18 2009 +0000
+++ b/libpurple/util.h	Sat May 02 04:02:53 2009 +0000
@@ -496,21 +496,6 @@
 char *purple_markup_linkify(const char *str);
 
 /**
- * Escape special HTML characters to their HTML entities.
- * This is almost the reverse of purple_unescape_html except that
- * this does not translate "\n" into "<br>".
- *
- * @param str The string in which to escape special characters.
- *
- * @return The text with the special characters escaped. You must
- *         g_free this string when finished with it.
- *
- * @see purple_unescape_html
- * @since 2.6.0
- */
-char *purple_escape_html(const char *str);
-
-/**
  * Unescapes HTML entities to their literal characters. Also translates
  * "<br>" to "\n".
  * For example "&amp;" is replaced by '&' and so on.