Elements that contain multiple CDATA sections are overwritten. Fix is

submitted to go-pkg-xmlx
This commit is contained in:
Chris Grindstaff 2013-03-28 16:07:22 -04:00
parent 583ce7f9e9
commit ae2d31d0ff
2 changed files with 40 additions and 0 deletions

View File

@ -56,6 +56,18 @@ func Test_RssAuthor(t *testing.T) {
}
}
func Test_CData(t *testing.T) {
content, _ := ioutil.ReadFile("testdata/iosBoardGameGeek.rss")
feed := New(1, true, chanHandler, itemHandler)
feed.FetchBytes("http://example.com", content, nil)
item := items[0]
expected := `<p>abc<div>"def"</div>ghi`
if item.Description != expected {
t.Errorf("Expected item.Description to be [%s] but item.Description=[%s]", expected, item.Description)
}
}
func chanHandler(feed *Feed, newchannels []*Channel) {
println(len(newchannels), "new channel(s) in", feed.Url)
}

28
testdata/iosBoardGameGeek.rss vendored Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0"?><rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>iOS Board Games | BoardGameGeek</title>
<image>
<url>http://geekdo-images.com/images/geeksm.gif</url>
<link>http://boardgamegeek.com/</link>
<title>iOS Board Games | BoardGameGeek</title>
</image>
<description>BoardGameGeek features information related to the board gaming hobby</description>
<language>en-us</language>
<pubDate>Thu, 28 Mar 2013 14:51:20 +0000</pubDate>
<lastBuildDate>Thu, 28 Mar 2013 14:51:20 +0000</lastBuildDate>
<link>http://boardgamegeek.com/</link>
<webMaster>webmaster@boardgamegeek.com</webMaster>
<item>
<title>iOS News: Stone Age 2.0 Released, Ravensburger March Sale Features San Juan, More Info on Las Vegas, Shifts Gets an Update and more...</title>
<description>&lt;p&gt;abc<![CDATA[<div>"def"</div>]]>ghi
</description>
<link>http://boardgamegeek.com/blogpost/18194/ios-news-stone-age-2-0-released-ravensburger-march</link>
<guid>http://boardgamegeek.com/blogpost/18194/ios-news-stone-age-2-0-released-ravensburger-march</guid>
<pubDate>Thu, 28 Mar 2013 14:51:20 +0000</pubDate>
<dc:creator>Neumannium</dc:creator>
</item>
</channel>
</rss>