aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Conway <john.a.conway@gmail.com>2019-05-17 18:57:04 +0100
committerJohn Conway <john.a.conway@gmail.com>2019-05-17 18:57:04 +0100
commit30ed0739aa64abdb1dc4372c6618c4c5f35cd992 (patch)
treeb04111f235c992ddcbd1e80c1f6152c194e5709e
parent80d3a0bda8e24220bf4b657a0f23114ac2fc3f2d (diff)
downloadfeed-nim-30ed0739aa64abdb1dc4372c6618c4c5f35cd992.tar.gz
feed-nim-30ed0739aa64abdb1dc4372c6618c4c5f35cd992.zip
[RSS] CData fix
-rw-r--r--src/FeedNim/rss.nim14
-rwxr-xr-xtests/test_rssbin470952 -> 480488 bytes
-rw-r--r--tests/test_rss.xml2
3 files changed, 10 insertions, 6 deletions
diff --git a/src/FeedNim/rss.nim b/src/FeedNim/rss.nim
index c65b13f..47f141a 100644
--- a/src/FeedNim/rss.nim
+++ b/src/FeedNim/rss.nim
@@ -97,11 +97,15 @@ func parseCategories( node: XmlNode ): seq[RSSCategory] =
return categories
func parseText ( node: XmlNode ): string =
- var content = node.innerText
- if content.len() > 14:
- if content[0 .. 8] == "<![CDATA[":
- return content.substr[9 .. content.len()-4 ]
- return content
+ var content = ""
+ for item in node.items:
+ content = content & $item
+ # Strip CDATA
+ if content[0 .. 8] == "<![CDATA[":
+ content = content.substr[9 .. content.len()-4 ]
+ return content
+ else:
+ return node.innerText
func parseItem( node: XmlNode) : RSSItem =
var item: RSSItem = RSSItem()
diff --git a/tests/test_rss b/tests/test_rss
index acdb45f..9d81d79 100755
--- a/tests/test_rss
+++ b/tests/test_rss
Binary files differ
diff --git a/tests/test_rss.xml b/tests/test_rss.xml
index 4432d9e..86cdfa7 100644
--- a/tests/test_rss.xml
+++ b/tests/test_rss.xml
@@ -46,7 +46,7 @@
<title>Aeroplanes not Airplanes</title>
<link>http://joe.bloggs/posts/1</link>
<pubDate>Sat, 07 Sep 2002 00:00:01 GMT</pubDate>
- <description>Aero- not air-, fools!</description>
+ <description><![CDATA[Aero- not air-, fools!]]></description>
<author>jane@joe.bloggs (Jane Bloggs)</author>
<category domain="http://awesomecategories.org" >Words</category>
<comments>http://joe.bloggs/posts/1/comments</comments>