diff --git a/src/base/rss/private/rss_parser.cpp b/src/base/rss/private/rss_parser.cpp index ecfb99812..d16b20f26 100644 --- a/src/base/rss/private/rss_parser.cpp +++ b/src/base/rss/private/rss_parser.cpp @@ -583,6 +583,7 @@ void Parser::parse_impl(const QByteArray &feedData) emit finished(m_result); m_result.articles.clear(); // clear articles only + m_articleIDs.clear(); } void Parser::parseRssArticle(QXmlStreamReader &xml) @@ -774,6 +775,20 @@ void Parser::addArticle(QVariantHash article) if (localId.toString().isEmpty()) localId = article.value(Article::KeyTitle); - if (!localId.toString().isEmpty()) - m_result.articles.prepend(article); + if (localId.toString().isEmpty()) { + // The article could not be uniquely identified + // since it has no appropriate data. + // Just ignore it. + return; + } + + if (m_articleIDs.contains(localId.toString())) { + // The article could not be uniquely identified + // since the Feed has duplicate identifiers. + // Just ignore it. + return; + } + + m_articleIDs.insert(localId.toString()); + m_result.articles.prepend(article); } diff --git a/src/base/rss/private/rss_parser.h b/src/base/rss/private/rss_parser.h index 01795af8c..3d0ed4e72 100644 --- a/src/base/rss/private/rss_parser.h +++ b/src/base/rss/private/rss_parser.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -69,6 +70,7 @@ namespace RSS QString m_baseUrl; ParsingResult m_result; + QSet m_articleIDs; }; } }