[totem-pl-parser/sam/xspf-title] Correctly parse XSPF title field




commit 2269ad97040f1c71c1f613a09054ad79be4ca20f
Author: Sam Thursfield <sam afuera me uk>
Date:   Fri Oct 23 01:29:42 2020 +0200

    Correctly parse XSPF title field
    
    Previously all XSPF playlists had the name "title".

 plparse/tests/parser.c         | 10 ++++++++++
 plparse/tests/playlist.xspf    |  1 +
 plparse/totem-pl-parser-xspf.c |  4 +++-
 3 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 64109ad..b9517a8 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -644,6 +644,15 @@ test_parsing_xspf_escaping (void)
        g_free (uri);
 }
 
+static void
+test_parsing_xspf_metadata (void)
+{
+       char *uri;
+       uri = get_relative_uri (TEST_SRCDIR "playlist.xspf");
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_TITLE), ==, "Test 
Playlist");
+       g_free (uri);
+}
+
 static void
 test_parsing_xspf_xml_base (void)
 {
@@ -1446,6 +1455,7 @@ main (int argc, char *argv[])
                g_test_add_func ("/parser/parsing/num_items_in_pls", test_parsing_num_entries);
                g_test_add_func ("/parser/parsing/xspf_genre", test_parsing_xspf_genre);
                g_test_add_func ("/parser/parsing/xspf_escaping", test_parsing_xspf_escaping);
+               g_test_add_func ("/parser/parsing/xspf_metadata", test_parsing_xspf_metadata);
                g_test_add_func ("/parser/parsing/xspf_xml_base", test_parsing_xspf_xml_base);
                g_test_add_func ("/parser/parsing/test_pl_content_type", test_pl_content_type);
                g_test_add_func ("/parser/parsing/itms_link", test_itms_parsing);
diff --git a/plparse/tests/playlist.xspf b/plparse/tests/playlist.xspf
index 413e70c..57c08a0 100644
--- a/plparse/tests/playlist.xspf
+++ b/plparse/tests/playlist.xspf
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <playlist version="1" xmlns="http://xspf.org/ns/0/";>
   <creator>audacious-plugins-1.4.5</creator>
+  <title>Test Playlist</title>
   <trackList>
     <track>
       <location>http://207.200.96.226:8000 extraparam=1</location>
diff --git a/plparse/totem-pl-parser-xspf.c b/plparse/totem-pl-parser-xspf.c
index f30883b..1a50316 100644
--- a/plparse/totem-pl-parser-xspf.c
+++ b/plparse/totem-pl-parser-xspf.c
@@ -473,7 +473,7 @@ parse_xspf_entries (TotemPlParser *parser,
                        continue;
 
                if (g_ascii_strcasecmp ((char *)node->name, "title") == 0) {
-                       title = node->name;
+                       title = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
                        break;
                }
        }
@@ -500,6 +500,8 @@ parse_xspf_entries (TotemPlParser *parser,
                g_free (uri);
        }
 
+       SAFE_FREE (title);
+
        return retval;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]