diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml
index 35c9cce90..4010dd183 100755
--- a/resources/desktop/com.github.rssguard.appdata.xml
+++ b/resources/desktop/com.github.rssguard.appdata.xml
@@ -30,7 +30,7 @@
https://martinrotter.github.io/donate/
-
+
none
diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp
index c7406d958..c3618edb6 100755
--- a/src/core/messagesmodel.cpp
+++ b/src/core/messagesmodel.cpp
@@ -85,7 +85,7 @@ void MessagesModel::loadMessages(RootItem* item) {
}
else {
if (!item->getParentServiceRoot()->loadMessagesForItem(item, this)) {
- setFilter(QSL("true != true"));
+ setFilter(QSL(DEFAULT_SQL_MESSAGES_FILTER));
qWarning("Loading of messages from item '%s' failed.", qPrintable(item->title()));
qApp->showGuiMessage(tr("Loading of messages from item '%1' failed.").arg(item->title()),
tr("Loading of messages failed, maybe messages could not be downloaded."),
@@ -500,7 +500,7 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootIt
msgs.append(msg);
message_ids.append(QString::number(msg.m_id));
- setData(index(message.row(), MSG_DB_READ_INDEX), (int) read);
+ setData(index(message.row(), MSG_DB_READ_INDEX), int(read));
}
reloadWholeLayout();
diff --git a/src/core/messagesmodelsqllayer.cpp b/src/core/messagesmodelsqllayer.cpp
index 3e1dbd454..8d655b45d 100755
--- a/src/core/messagesmodelsqllayer.cpp
+++ b/src/core/messagesmodelsqllayer.cpp
@@ -87,8 +87,9 @@ QString MessagesModelSqlLayer::formatFields() const {
}
QString MessagesModelSqlLayer::selectStatement() const {
- return QL1S("SELECT ") + formatFields() +
- QSL(" FROM Messages LEFT JOIN Feeds ON Messages.feed = Feeds.custom_id AND Messages.account_id = Feeds.account_id WHERE ") +
+ return QL1S("SELECT ") + formatFields() + QL1C(' ') +
+ QL1S("FROM Messages LEFT JOIN Feeds ON Messages.feed = Feeds.custom_id AND Messages.account_id = Feeds.account_id "
+ "WHERE ") +
m_filter + orderByClause() + QL1C(';');
}
diff --git a/src/definitions/definitions.h b/src/definitions/definitions.h
index 3b0473c0d..d31cf5848 100755
--- a/src/definitions/definitions.h
+++ b/src/definitions/definitions.h
@@ -91,8 +91,8 @@
#define FEED_INITIAL_OPML_PATTERN "feeds-%1.opml"
-#define FEED_REGEX_MATCHER "]+type=\\\"application/(atom|rss)\\+xml\\\"[^>]*>"
-#define FEED_HREF_REGEX_MATCHER "href\\=\\\"[^\\\"]+\\\""
+#define FEED_REGEX_MATCHER "]+type=\"application\\/(?:atom|rss)\\+xml\"[^>]*>"
+#define FEED_HREF_REGEX_MATCHER "href=\"([^\"]+)\""
#define PLACEHOLDER_UNREAD_COUNTS "%unread"
#define PLACEHOLDER_ALL_COUNTS "%all"
diff --git a/src/network-web/networkfactory.cpp b/src/network-web/networkfactory.cpp
index 50eafcbdf..9665737bf 100755
--- a/src/network-web/networkfactory.cpp
+++ b/src/network-web/networkfactory.cpp
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
#include
#include
@@ -17,25 +18,26 @@ NetworkFactory::NetworkFactory() {}
QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html) {
QStringList feeds;
- const QRegExp rx(FEED_REGEX_MATCHER, Qt::CaseInsensitive);
- const QRegExp rx_href(FEED_HREF_REGEX_MATCHER, Qt::CaseInsensitive);
+ QRegularExpression rx(FEED_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
+ QRegularExpression rx_href(FEED_HREF_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
- for (int pos = 0; (pos = rx.indexIn(html, pos)) != -1; pos += rx.matchedLength()) {
- QString link_element = html.mid(pos, rx.matchedLength());
+ rx_href.optimize();
- if (rx_href.indexIn(link_element) != -1) {
- QString href_attribute = rx_href.capturedTexts().at(0);
- QString feed_link = href_attribute.mid(6, href_attribute.size() - 7);
+ QRegularExpressionMatchIterator it_rx = rx.globalMatch(html);
- if (feed_link.startsWith(QL1S("//"))) {
- feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2);
- }
- else if (feed_link.startsWith(QL1C('/'))) {
- feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link;
- }
+ while (it_rx.hasNext()) {
+ QRegularExpressionMatch mat_tx = it_rx.next();
+ QString link_tag = mat_tx.captured();
+ QString feed_link = rx_href.match(link_tag).captured(1);
- feeds.append(feed_link);
+ if (feed_link.startsWith(QL1S("//"))) {
+ feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2);
}
+ else if (feed_link.startsWith(QL1C('/'))) {
+ feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link;
+ }
+
+ feeds.append(feed_link);
}
return feeds;
diff --git a/src/services/abstract/serviceroot.cpp b/src/services/abstract/serviceroot.cpp
index 3b2dfb1d9..78faf7f7b 100755
--- a/src/services/abstract/serviceroot.cpp
+++ b/src/services/abstract/serviceroot.cpp
@@ -538,12 +538,13 @@ bool ServiceRoot::onAfterMessagesDelete(RootItem* selected_item, const QListupdateCounts(true);
- RecycleBin* bin = recycleBin();
if (selected_item->kind() == RootItemKind::Bin) {
- itemChanged(QList() << bin);
+ itemChanged(QList() << selected_item);
}
else {
+ RecycleBin* bin = recycleBin();
+
if (bin != nullptr) {
bin->updateCounts(true);
itemChanged(QList() << selected_item << bin);
diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp
index 41fef3248..ffb0c84f2 100755
--- a/src/services/standard/standardfeed.cpp
+++ b/src/services/standard/standardfeed.cpp
@@ -155,23 +155,21 @@ QPair StandardFeed::guessFeed(const
result.second = network_result.first;
if (result.second == QNetworkReply::NoError || !feed_contents.isEmpty()) {
+ if (result.first == nullptr) {
+ result.first = new StandardFeed();
+ }
+
// Feed XML was obtained, now we need to try to guess
// its encoding before we can read further data.
QString xml_schema_encoding;
QString xml_contents_encoded;
- QRegExp encoding_rexp(QSL("encoding=\"[^\"]\\S+\""));
+ QString enc = QRegularExpression(QSL("encoding=\"([A-Z0-9\\-]+)\""),
+ QRegularExpression::PatternOption::CaseInsensitiveOption).match(feed_contents).captured(1);
- if (encoding_rexp.indexIn(feed_contents) != -1 &&
- !(xml_schema_encoding = encoding_rexp.cap(0)).isEmpty()) {
+ if (!enc.isEmpty()) {
// Some "encoding" attribute was found get the encoding
// out of it.
- encoding_rexp.setPattern(QSL("[^\"]\\S+[^\"]"));
- encoding_rexp.indexIn(xml_schema_encoding, 9);
- xml_schema_encoding = encoding_rexp.cap(0);
- }
-
- if (result.first == nullptr) {
- result.first = new StandardFeed();
+ xml_schema_encoding = enc;
}
QTextCodec* custom_codec = QTextCodec::codecForName(xml_schema_encoding.toLocal8Bit());