summaryrefslogtreecommitdiff
path: root/test/rsspp_parser.cpp
diff options
context:
space:
mode:
authorGravatar Alexander Batischev <eual.jp@gmail.com> 2019-06-09 13:32:27 +0300
committerGravatar Alexander Batischev <eual.jp@gmail.com> 2019-06-09 13:33:41 +0300
commitef4e93ce169d6f6c50697913d7bf92a9218bd5a4 (patch)
tree43119f0473acbae394b7575c3fec8660b6e04af1 /test/rsspp_parser.cpp
parent604ac12059522620c12a8f345b78d5a84a73dfe1 (diff)
downloadnewsboat-ef4e93ce169d6f6c50697913d7bf92a9218bd5a4.tar.gz
newsboat-ef4e93ce169d6f6c50697913d7bf92a9218bd5a4.tar.zst
newsboat-ef4e93ce169d6f6c50697913d7bf92a9218bd5a4.zip
Fix out-of-bounds access on empty author tag in RSS 0.9x
Fixes #542.
Diffstat (limited to '')
-rw-r--r--test/rsspp_parser.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/rsspp_parser.cpp b/test/rsspp_parser.cpp
index 04978612..e99283ac 100644
--- a/test/rsspp_parser.cpp
+++ b/test/rsspp_parser.cpp
@@ -49,6 +49,48 @@ TEST_CASE("Extracts data from RSS 0.91", "[rsspp::Parser]")
REQUIRE(f.items[0].guid == "");
}
+TEST_CASE("Doesn't crash or garble data if an item in RSS 0.9x contains "
+ "an empty author tag",
+ "[rsspp::Parser][issue542]")
+{
+ rsspp::Parser p;
+ rsspp::Feed f;
+
+ SECTION("RSS 0.91") {
+ REQUIRE_NOTHROW(f = p.parse_file("data/rss_091_with_empty_author.xml"));
+ REQUIRE(f.rss_version == rsspp::Feed::RSS_0_91);
+ }
+
+ SECTION("RSS 0.92") {
+ REQUIRE_NOTHROW(f = p.parse_file("data/rss_092_with_empty_author.xml"));
+ REQUIRE(f.rss_version == rsspp::Feed::RSS_0_92);
+ }
+
+ SECTION("RSS 0.94") {
+ REQUIRE_NOTHROW(f = p.parse_file("data/rss_094_with_empty_author.xml"));
+ REQUIRE(f.rss_version == rsspp::Feed::RSS_0_94);
+ }
+
+ REQUIRE(f.title == "A Channel with Unnamed Authors");
+ REQUIRE(f.description == "an example feed");
+ REQUIRE(f.link == "http://example.com/");
+ REQUIRE(f.language == "en");
+
+ REQUIRE(f.items.size() == 2u);
+
+ REQUIRE(f.items[0].title == "This one has en empty author tag");
+ REQUIRE(f.items[0].link == "http://example.com/test_1.html");
+ REQUIRE(f.items[0].description == "It doesn't matter.");
+ REQUIRE(f.items[0].author == "");
+ REQUIRE(f.items[0].guid == "");
+
+ REQUIRE(f.items[1].title == "This one has en empty author tag as well");
+ REQUIRE(f.items[1].link == "http://example.com/test_2.html");
+ REQUIRE(f.items[1].description == "Non-empty description though.");
+ REQUIRE(f.items[1].author == "");
+ REQUIRE(f.items[1].guid == "");
+}
+
TEST_CASE("Extracts data from RSS 0.92", "[rsspp::Parser]")
{
rsspp::Parser p;