diff libpurple/theme.c @ 25119:fc8047e1fa39

fixed some leaks and made theme loading safer
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Fri, 08 Aug 2008 21:26:12 +0000
parents 748308865dbf
children 1eacf60a73dd
line wrap: on
line diff
--- a/libpurple/theme.c	Fri Aug 08 20:56:44 2008 +0000
+++ b/libpurple/theme.c	Fri Aug 08 21:26:12 2008 +0000
@@ -22,6 +22,9 @@
  */
 
 #include "theme.h"
+#include "util.h"
+
+#include <string.h>
 
 #define PURPLE_THEME_GET_PRIVATE(PurpleTheme) \
 	((PurpleThemePrivate *) ((PurpleTheme)->priv))
@@ -230,9 +233,21 @@
   return type;
 }
 
+/******************************************************************************
+ * Helper Functions
+ *****************************************************************************/
+
+static gchar*
+theme_clean_text(const gchar *text)
+{
+	gchar *clean_text = g_markup_escape_text(text, strlen(text));	
+	g_strdelimit(clean_text, "\n", ' ');
+	purple_str_strip_char(clean_text, '\r');
+	return clean_text;
+}
 
 /*****************************************************************************
- * Public API functions                                                      *
+ * Public API functions                                                      
  *****************************************************************************/
 
 const gchar *
@@ -256,7 +271,7 @@
 	priv = PURPLE_THEME_GET_PRIVATE(theme);
 
 	g_free(priv->name);
-	priv->name = g_strdup(name);
+	priv->name = theme_clean_text(name);
 }
 
 const gchar *
@@ -280,7 +295,7 @@
 	priv = PURPLE_THEME_GET_PRIVATE(theme);
 
 	g_free(priv->description);
-	priv->description = g_strdup(description);
+	priv->description = theme_clean_text(description);
 }
 
 const gchar *
@@ -304,7 +319,7 @@
 	priv = PURPLE_THEME_GET_PRIVATE(theme);
 
 	g_free(priv->author);
-	priv->author = g_strdup(author);
+	priv->author = theme_clean_text(author);
 }
 
 const gchar *