changeset 3088:27e2dbb89226

xspf: add XML entity encoding into xspf_add_node for string nodes.
author Jussi Judin <jjudin+audacious@iki.fi>
date Thu, 30 Apr 2009 06:14:00 -0500
parents f333e6df5fa9
children 85a35e03b0c9
files src/xspf/xspf.c
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/xspf/xspf.c	Wed Apr 29 21:12:44 2009 -0500
+++ b/src/xspf/xspf.c	Thu Apr 30 06:14:00 2009 -0500
@@ -313,12 +313,13 @@
 }
 
 
-static void xspf_add_node(xmlNodePtr node, TupleValueType type,
+static void xspf_add_node(xmlDocPtr doc, xmlNodePtr node, TupleValueType type,
         gboolean isMeta, const gchar *xspfName, const gchar *strVal,
         const gint intVal)
 {
     gchar tmps[64];
     xmlNodePtr tmp;
+    xmlChar *encVal;
     
     if (isMeta) {
         tmp = xmlNewNode(NULL, (xmlChar *) "meta");
@@ -328,7 +329,9 @@
     
     switch (type) {
         case TUPLE_STRING:
-            xmlAddChild(tmp, xmlNewText((xmlChar *) strVal));
+            encVal = xmlEncodeEntitiesReentrant(doc, (xmlChar *)strVal);
+            xmlAddChild(tmp, xmlNewText(encVal));
+            free(encVal);
             break;
             
         case TUPLE_INT:
@@ -432,7 +435,7 @@
 
     /* common */
     xmlDocSetRootElement(doc, rootnode);
-    xspf_add_node(rootnode, TUPLE_STRING, FALSE, "creator", PACKAGE "-" VERSION, 0);
+    xspf_add_node(doc, rootnode, TUPLE_STRING, FALSE, "creator", PACKAGE "-" VERSION, 0);
 
     /* add staticlist marker */
     if (playlist->attribute & PLAYLIST_STATIC) {
@@ -451,7 +454,7 @@
     /* save playlist title */
     if (playlist->title && playlist->title[0] &&
         g_utf8_validate(playlist->title, -1, NULL))
-        xspf_add_node(rootnode, TUPLE_STRING, FALSE, "title", playlist->title, 0);
+        xspf_add_node(doc, rootnode, TUPLE_STRING, FALSE, "title", playlist->title, 0);
 
 
     tracklist = xmlNewNode(NULL, (xmlChar *)"trackList");
@@ -519,19 +522,19 @@
                 }
                 
                 if (isOK)
-                    xspf_add_node(track, xs->type, xs->isMeta, xs->xspfName, scratch, scratchi);
+                    xspf_add_node(doc, track, xs->type, xs->isMeta, xs->xspfName, scratch, scratchi);
             }
 
         } else {
 
             if (entry->title != NULL && g_utf8_validate(entry->title, -1, NULL))
-                xspf_add_node(track, TUPLE_STRING, FALSE, "title", entry->title, 0);
+                xspf_add_node(doc, track, TUPLE_STRING, FALSE, "title", entry->title, 0);
 
             if (entry->length > 0)
-                xspf_add_node(track, TUPLE_INT, FALSE, "duration", NULL, entry->length);
+                xspf_add_node(doc, track, TUPLE_INT, FALSE, "duration", NULL, entry->length);
 
             /* Add mtime of -1 */
-            xspf_add_node(track, TUPLE_INT, TRUE, "mtime", NULL, -1);
+            xspf_add_node(doc, track, TUPLE_INT, TRUE, "mtime", NULL, -1);
         }
 
         g_free(filename);