Fix #412 - bad logic when no author detected in ATOM entry

This commit is contained in:
Martin Rotter 2021-05-17 13:25:25 +02:00
parent b2409ab745
commit adeb9752fe
2 changed files with 10 additions and 4 deletions

View File

@ -23,11 +23,17 @@ AtomParser::AtomParser(const QString& data) : FeedParser(data) {
AtomParser::~AtomParser() = default;
QString AtomParser::feedAuthor() const {
QDomNodeList authors = m_xml.documentElement().elementsByTagNameNS(m_atomNamespace, QSL("author"));
QDomNodeList top_level_nodes = m_xml.documentElement().childNodes();
QStringList author_str;
for (int i = 0; i < authors.size(); i++) {
QDomNodeList names = authors.at(i).toElement().elementsByTagNameNS(m_atomNamespace, QSL("name"));
for (int i = 0; i < top_level_nodes.size(); i++) {
auto elem = top_level_nodes.at(i).toElement();
if (elem.localName() != QSL("author") || elem.namespaceURI() != m_atomNamespace) {
continue;
}
QDomNodeList names = elem.elementsByTagNameNS(m_atomNamespace, QSL("name"));
if (!names.isEmpty()) {
const QString name = names.at(0).toElement().text();

View File

@ -28,7 +28,7 @@ QList<Message> FeedParser::messages() {
try {
Message new_message = extractMessage(message_item.toElement(), current_time);
if (new_message.m_author.isEmpty()) {
if (new_message.m_author.isEmpty() && !feed_author.isEmpty()) {
new_message.m_author = feed_author;
}