diff options
author | crvi <crvisqr@gmail.com> | 2021-04-07 04:02:50 +0530 |
---|---|---|
committer | crvi <crvisqr@gmail.com> | 2021-04-24 00:02:19 +0530 |
commit | e13178528ac4bd166ad22fc981916cc015f7c25e (patch) | |
tree | 1b1bf3f4b98a832d6f66a37b66feb1ed47fefdc6 | |
parent | 0b89b79c50d9a0a22f23d1ba40a73f9f3cd54da2 (diff) | |
download | totem-pl-parser-e13178528ac4bd166ad22fc981916cc015f7c25e.tar.gz |
tests: fix garbage in CDATA values for shorter texts
-rw-r--r-- | plparse/tests/cdata.rss | 50 | ||||
-rw-r--r-- | plparse/tests/parser.c | 32 |
2 files changed, 82 insertions, 0 deletions
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 @@ -1021,6 +1021,37 @@ test_invalid_utf8_characters (void) } 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) { if (g_strcmp0 (g_get_user_name (), "hadess") == 0) @@ -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); |