[totem-pl-parser] tests: fix garbage in CDATA values for shorter texts



commit e13178528ac4bd166ad22fc981916cc015f7c25e
Author: crvi <crvisqr gmail com>
Date:   Wed Apr 7 04:02:50 2021 +0530

    tests: fix garbage in CDATA values for shorter texts

 plparse/tests/cdata.rss | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
 plparse/tests/parser.c  | 32 +++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
---
diff --git a/plparse/tests/cdata.rss b/plparse/tests/cdata.rss
new file mode 100644
index 0000000..11cc5b7
--- /dev/null
+++ b/plparse/tests/cdata.rss
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:content="http://purl.org/rss/1.0/modules/content/"; xmlns:atom="http://www.w3.org/2005/Atom"; 
version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"; 
xmlns:anchor="https://anchor.fm/xmlns";>
+       <channel>
+               <title><![CDATA[POLL]]></title>
+               <description><![CDATA[POLL (Podcast LPM LONTAR) merupakan sebuah media yang kami gunakan 
untuk menyalurkan potensi anggota LPM LONTAR dengan menyajikan beragam topik diskusi.]]></description>
+               <link>https://anchor.fm/poll1</link>
+               <image>
+                       
<url>https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded/3822711/3822711-1584696597464-3f56d16d84da.jpg</url>
+                       <title>POLL</title>
+                       <link>https://anchor.fm/poll1</link>
+               </image>
+               <generator>Anchor Podcasts</generator>
+               <lastBuildDate>Tue, 06 Apr 2021 02:07:46 GMT</lastBuildDate>
+               <atom:link href="https://anchor.fm/s/176194fc/podcast/rss"; rel="self" 
type="application/rss+xml"/>
+               <author><![CDATA[POLL]]></author>
+               <webMaster><![CDATA[X]]></webMaster>
+               <copyright><![CDATA[]]></copyright>
+               <language><![CDATA[in]]></language>
+               <atom:link rel="hub" href="https://pubsubhubbub.appspot.com/"/>
+               <itunes:author><![CDATA[POLL author]]></itunes:author>
+               <itunes:summary>POLL (Podcast LPM LONTAR) merupakan sebuah media yang kami gunakan untuk 
menyalurkan potensi anggota LPM LONTAR dengan menyajikan beragam topik diskusi.</itunes:summary>
+               <itunes:type>episodic</itunes:type>
+               <itunes:owner>
+                       <itunes:name>POLL</itunes:name>
+                       <itunes:email>podcasts37+176194fc anchor fm</itunes:email>
+               </itunes:owner>
+               <itunes:explicit>No</itunes:explicit>
+               <itunes:category text="Education">
+                       <itunes:category text="Self-Improvement"/>
+               </itunes:category>
+               <itunes:image 
href="https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded/3822711/3822711-1584696597464-3f56d16d84da.jpg"/>
+               <item>
+                       <title><![CDATA[POLL#1 "MAHASISWA" with Dimas AP]]></title>
+                       <description><![CDATA[POLL#1 kali ini LPM LONTAR mencoba mengulik makna mahasiswa 
dari kacamata seorang Dimas AP mahasiswa Teknik Industri UMG
+]]></description>
+                       <link>https://anchor.fm/poll1/episodes/POLL1-MAHASISWA-with-Dimas-AP-ebn40u</link>
+                       <guid 
isPermaLink="false">https://anchor.fm/poll1/episodes/POLL1-MAHASISWA-with-Dimas-AP-ebn40u</guid>
+                       <dc:creator><![CDATA[POLL]]></dc:creator>
+                       <pubDate>Fri, 20 Mar 2020 09:20:00 GMT</pubDate>
+                       <enclosure 
url="https://anchor.fm/s/176194fc/podcast/play/11292126/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fproduction%2F2020-2-20%2F57676097-48000-1-f743da4d9e9f9.mp3";
 length="28591917" type="audio/mpeg"/>
+                       <itunes:summary>POLL#1 kali ini LPM LONTAR mencoba mengulik makna mahasiswa dari 
kacamata seorang Dimas AP mahasiswa Teknik Industri UMG
+</itunes:summary>
+                       <itunes:explicit>No</itunes:explicit>
+                       <itunes:duration>1786</itunes:duration>
+                       <itunes:image 
href="https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded/3822711/3822711-1584696597464-3f56d16d84da.jpg"/>
+                       <itunes:season>1</itunes:season>
+                       <itunes:episode>1</itunes:episode>
+                       <itunes:episodeType>full</itunes:episodeType>
+               </item>
+       </channel>
+</rss>
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 5271779..56be7d4 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -1020,6 +1020,37 @@ test_invalid_utf8_characters (void)
        g_free (uri);
 }
 
+static void
+test_parsing_xml_cdata (void)
+{
+       char *uri;
+       const char *description =
+               "POLL (Podcast LPM LONTAR) merupakan sebuah media yang kami gunakan "
+               "untuk menyalurkan potensi anggota LPM LONTAR dengan menyajikan beragam topik diskusi.";
+
+       uri = get_relative_uri (TEST_SRCDIR "cdata.rss");
+
+       /* empty cdata */
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_COPYRIGHT), ==, NULL);
+
+       /* single char */
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_CONTACT), ==, "X");
+
+       /* two chars */
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_LANGUAGE), ==, "in");
+
+       /* one word */
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_TITLE), ==, "POLL");
+
+       /* two words */
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_AUTHOR), ==, "POLL 
author");
+
+       /* long string */
+       g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_DESCRIPTION), ==, 
description);
+
+       g_free (uri);
+}
+
 static void
 test_parsing_hadess (void)
 {
@@ -1786,6 +1817,7 @@ main (int argc, char *argv[])
                g_test_add_func ("/parser/parsing/live_streaming", test_parsing_live_streaming);
                g_test_add_func ("/parser/parsing/xml_mixed_cdata", test_parsing_xml_mixed_cdata);
                g_test_add_func ("/parser/parsing/m3u_streaming", test_parsing_m3u_streaming);
+               g_test_add_func ("/parser/parsing/xml_cdata", test_parsing_xml_cdata);
 #ifdef HAVE_QUVI
                g_test_add_func ("/parser/videosite", test_videosite);
                g_test_add_func ("/parser/parsing/rss_id", test_parsing_rss_id);


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