diff options
author | mio <stigma@disroot.org> | 2025-03-14 19:50:48 +1000 |
---|---|---|
committer | mio <stigma@disroot.org> | 2025-03-14 20:11:20 +1000 |
commit | 81d428dedb2fa9f14ddef3edfa4d68c0d58af528 (patch) | |
tree | 74d9bce5afcd161ab2caa825c96e9a574cb382bc /akregator/src/librss/article.cpp | |
parent | b69050d6e8956d0f38c526b9fca93d76fccffeac (diff) | |
download | tdepim-81d428dedb2fa9f14ddef3edfa4d68c0d58af528.tar.gz tdepim-81d428dedb2fa9f14ddef3edfa4d68c0d58af528.zip |
akregator-librss: use namespaces
Check element namespace rather than assuming a prefix, which can result
in incorrect metadata displaying.
Signed-off-by: mio <stigma@disroot.org>
Diffstat (limited to 'akregator/src/librss/article.cpp')
-rw-r--r-- | akregator/src/librss/article.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/akregator/src/librss/article.cpp b/akregator/src/librss/article.cpp index 18522fe3..88d42a7d 100644 --- a/akregator/src/librss/article.cpp +++ b/akregator/src/librss/article.cpp @@ -92,13 +92,16 @@ Article::Article(const TQDomNode &node, Format format, Version version) : d(new d->link = elemText; } + // prefer content/content:encoded over summary/description for feeds that provide it + if (format == AtomFeed) + { + d->description = extractNode(node, TQString::fromLatin1("content"), false); + } + else + { + d->description = extractElementTextNS(node, ContentNamespace, TQString::fromLatin1("encoded"), false); + } - // prefer content/content:encoded over summary/description for feeds that provide it - TQString tagName=(format==AtomFeed)? TQString::fromLatin1("content"): TQString::fromLatin1("content:encoded"); - - if (!(elemText = extractNode(node, tagName, false)).isNull()) - d->description = elemText; - if (d->description.isEmpty()) { if (!(elemText = extractNode(node, TQString::fromLatin1("body"), false)).isNull()) @@ -130,7 +133,7 @@ Article::Article(const TQDomNode &node, Format format, Version version) : d(new time = KRFCDate::parseDate(elemText); } - if (!(elemText = extractNode(node, TQString::fromLatin1("dc:date"))).isNull()) + if (!(elemText = extractElementTextNS(node, DublinCoreNamespace, TQString::fromLatin1("date"))).isNull()) { time = parseISO8601Date(elemText); } @@ -139,27 +142,22 @@ Article::Article(const TQDomNode &node, Format format, Version version) : d(new if (time != 0) d->pubDate.setTime_t(time); - if (!(elemText = extractNode(node, TQString::fromLatin1("wfw:comment"))).isNull()) { - d->commentsLink = elemText; - } - - if (!(elemText = extractNode(node, TQString::fromLatin1("slash:comments"))).isNull()) { - d->numComments = elemText.toInt(); - } + d->commentsLink = extractElementTextNS(node, CommentAPINamespace, TQString::fromLatin1("comment")); + d->numComments = extractElementTextNS(node, SlashNamespace, TQString::fromLatin1("comments")).toInt(); TQDomElement element = TQDomNode(node).toElement(); // in RSS 1.0, we use <item about> attribute as ID // FIXME: pass format version instead of checking for attribute - if (!element.isNull() && element.hasAttribute(TQString::fromLatin1("rdf:about"))) + if (!element.isNull() && element.hasAttributeNS(RDFNamespace, TQString::fromLatin1("about"))) { - d->guid = element.attribute(TQString::fromLatin1("rdf:about")); // HACK: using ns properly did not work + d->guid = element.attributeNS(RDFNamespace, TQString::fromLatin1("about"), TQString::null); d->guidIsPermaLink = false; } else { - tagName=(format==AtomFeed)? TQString::fromLatin1("id"): TQString::fromLatin1("guid"); + TQString tagName=(format==AtomFeed)? TQString::fromLatin1("id"): TQString::fromLatin1("guid"); TQDomNode n = node.namedItem(tagName); if (!n.isNull()) { |