mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 13:58:51 +03:00
[RSS] Trim elements text in RSS articles
This commit is contained in:
parent
c3592304b6
commit
b9b7786477
1 changed files with 10 additions and 10 deletions
|
@ -254,7 +254,7 @@ void RssParser::parseRssArticle(QXmlStreamReader& xml, const QString& feedUrl)
|
||||||
|
|
||||||
if (xml.isStartElement()) {
|
if (xml.isStartElement()) {
|
||||||
if (xml.name() == "title")
|
if (xml.name() == "title")
|
||||||
article["title"] = xml.readElementText();
|
article["title"] = xml.readElementText().trimmed();
|
||||||
else if (xml.name() == "enclosure") {
|
else if (xml.name() == "enclosure") {
|
||||||
if (xml.attributes().value("type") == "application/x-bittorrent")
|
if (xml.attributes().value("type") == "application/x-bittorrent")
|
||||||
article["torrent_url"] = xml.attributes().value("url").toString();
|
article["torrent_url"] = xml.attributes().value("url").toString();
|
||||||
|
@ -267,13 +267,13 @@ void RssParser::parseRssArticle(QXmlStreamReader& xml, const QString& feedUrl)
|
||||||
article["news_link"] = link;
|
article["news_link"] = link;
|
||||||
}
|
}
|
||||||
else if (xml.name() == "description")
|
else if (xml.name() == "description")
|
||||||
article["description"] = xml.readElementText();
|
article["description"] = xml.readElementText().trimmed();
|
||||||
else if (xml.name() == "pubDate")
|
else if (xml.name() == "pubDate")
|
||||||
article["date"] = parseDate(xml.readElementText());
|
article["date"] = parseDate(xml.readElementText().trimmed());
|
||||||
else if (xml.name() == "author")
|
else if (xml.name() == "author")
|
||||||
article["author"] = xml.readElementText();
|
article["author"] = xml.readElementText().trimmed();
|
||||||
else if (xml.name() == "guid")
|
else if (xml.name() == "guid")
|
||||||
article["id"] = xml.readElementText();
|
article["id"] = xml.readElementText().trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ void RssParser::parseAtomArticle(QXmlStreamReader& xml, const QString& feedUrl,
|
||||||
// Workaround for CDATA (QString cannot parse html escapes on it's own)
|
// Workaround for CDATA (QString cannot parse html escapes on it's own)
|
||||||
QTextDocument doc;
|
QTextDocument doc;
|
||||||
doc.setHtml(xml.readElementText());
|
doc.setHtml(xml.readElementText());
|
||||||
article["title"] = doc.toPlainText();
|
article["title"] = doc.toPlainText().trimmed();
|
||||||
}
|
}
|
||||||
else if (xml.name() == "link") {
|
else if (xml.name() == "link") {
|
||||||
QString link = ( xml.attributes().isEmpty() ?
|
QString link = ( xml.attributes().isEmpty() ?
|
||||||
|
@ -373,13 +373,13 @@ void RssParser::parseAtomArticle(QXmlStreamReader& xml, const QString& feedUrl,
|
||||||
// Actually works great for non-broken content too
|
// Actually works great for non-broken content too
|
||||||
QString feedText = xml.readElementText(QXmlStreamReader::IncludeChildElements);
|
QString feedText = xml.readElementText(QXmlStreamReader::IncludeChildElements);
|
||||||
if (!feedText.isEmpty())
|
if (!feedText.isEmpty())
|
||||||
article["description"] = feedText;
|
article["description"] = feedText.trimmed();
|
||||||
|
|
||||||
double_content = true;
|
double_content = true;
|
||||||
}
|
}
|
||||||
else if (xml.name() == "updated"){
|
else if (xml.name() == "updated"){
|
||||||
// ATOM uses standard compliant date, don't do fancy stuff
|
// ATOM uses standard compliant date, don't do fancy stuff
|
||||||
QDateTime articleDate = QDateTime::fromString(xml.readElementText(), Qt::ISODate);
|
QDateTime articleDate = QDateTime::fromString(xml.readElementText().trimmed(), Qt::ISODate);
|
||||||
article["date"] = ( articleDate.isValid() ?
|
article["date"] = ( articleDate.isValid() ?
|
||||||
articleDate :
|
articleDate :
|
||||||
QDateTime::currentDateTime() );
|
QDateTime::currentDateTime() );
|
||||||
|
@ -388,12 +388,12 @@ void RssParser::parseAtomArticle(QXmlStreamReader& xml, const QString& feedUrl,
|
||||||
xml.readNext();
|
xml.readNext();
|
||||||
while(xml.name() != "author") {
|
while(xml.name() != "author") {
|
||||||
if(xml.name() == "name")
|
if(xml.name() == "name")
|
||||||
article["author"] = xml.readElementText();
|
article["author"] = xml.readElementText().trimmed();
|
||||||
xml.readNext();
|
xml.readNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (xml.name() == "id")
|
else if (xml.name() == "id")
|
||||||
article["id"] = xml.readElementText();
|
article["id"] = xml.readElementText().trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue