use some default mime type for enclosure when missing

This commit is contained in:
Martin Rotter 2022-01-10 07:31:07 +01:00
parent daa889ee95
commit b0b3acf1c2
6 changed files with 21 additions and 6 deletions

View File

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url> <url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="4.1.0" date="2022-01-07"/> <release version="4.1.0" date="2022-01-10"/>
</releases> </releases>
<content_rating type="oars-1.0"> <content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute> <content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -26,10 +26,10 @@ CookieJar::CookieJar(QObject* parent) : QNetworkCookieJar(parent) {
// When cookies change in WebEngine, then change in main cookie jar too. // When cookies change in WebEngine, then change in main cookie jar too.
connect(m_webEngineCookies, &QWebEngineCookieStore::cookieAdded, this, [=](const QNetworkCookie& cookie) { connect(m_webEngineCookies, &QWebEngineCookieStore::cookieAdded, this, [=](const QNetworkCookie& cookie) {
insertCookieInternal(cookie, false, true); //insertCookieInternal(cookie, false, true);
}); });
connect(m_webEngineCookies, &QWebEngineCookieStore::cookieRemoved, this, [=](const QNetworkCookie& cookie) { connect(m_webEngineCookies, &QWebEngineCookieStore::cookieRemoved, this, [=](const QNetworkCookie& cookie) {
deleteCookieInternal(cookie, false); //deleteCookieInternal(cookie, false);
}); });
#endif #endif
@ -124,7 +124,6 @@ bool CookieJar::insertCookieInternal(const QNetworkCookie& cookie, bool notify_o
#if defined(USE_WEBENGINE) #if defined(USE_WEBENGINE)
if (notify_others) { if (notify_others) {
// NOTE: Make sync one-way for now, it crashes.
//m_webEngineCookies->setCookie(cookie); //m_webEngineCookies->setCookie(cookie);
} }
#else #else

View File

@ -100,7 +100,13 @@ Message AtomParser::extractMessage(const QDomElement& msg_element, const QDateTi
QString attribute = link.attribute(QSL("rel")); QString attribute = link.attribute(QSL("rel"));
if (attribute == QSL("enclosure")) { if (attribute == QSL("enclosure")) {
new_message.m_enclosures.append(Enclosure(link.attribute(QSL("href")), link.attribute(QSL("type")))); QString enclosure_type = link.attribute(QSL("type"));
if (enclosure_type.isEmpty()) {
enclosure_type = QSL(DEFAULT_ENCLOSURE_MIME_TYPE);
}
new_message.m_enclosures.append(Enclosure(link.attribute(QSL("href")), enclosure_type));
qDebugNN << LOGSEC_CORE qDebugNN << LOGSEC_CORE
<< "Found enclosure" << "Found enclosure"
<< QUOTE_W_SPACE(new_message.m_enclosures.last().m_url) << QUOTE_W_SPACE(new_message.m_enclosures.last().m_url)

View File

@ -4,5 +4,6 @@
#define DEFAULT_FEED_ENCODING "UTF-8" #define DEFAULT_FEED_ENCODING "UTF-8"
#define DEFAULT_FEED_TYPE "RSS" #define DEFAULT_FEED_TYPE "RSS"
#define FEED_INITIAL_OPML_PATTERN "feeds-%1.opml" #define FEED_INITIAL_OPML_PATTERN "feeds-%1.opml"
#define DEFAULT_ENCLOSURE_MIME_TYPE "image/jpg"
#endif // STANDARD_DEFINITIONS_H #endif // STANDARD_DEFINITIONS_H

View File

@ -5,6 +5,7 @@
#include "exceptions/applicationexception.h" #include "exceptions/applicationexception.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "network-web/webfactory.h" #include "network-web/webfactory.h"
#include "services/standard/definitions.h"
#include <QDebug> #include <QDebug>
#include <QRegularExpression> #include <QRegularExpression>
@ -60,6 +61,10 @@ QList<Enclosure> FeedParser::mrssGetEnclosures(const QDomElement& msg_element) c
QString url = elem_content.attribute(QSL("url")); QString url = elem_content.attribute(QSL("url"));
QString type = elem_content.attribute(QSL("type")); QString type = elem_content.attribute(QSL("type"));
if (type.isEmpty()) {
type = QSL(DEFAULT_ENCLOSURE_MIME_TYPE);
}
if (!url.isEmpty() && !type.isEmpty()) { if (!url.isEmpty() && !type.isEmpty()) {
enclosures.append(Enclosure(url, type)); enclosures.append(Enclosure(url, type));
} }
@ -72,7 +77,7 @@ QList<Enclosure> FeedParser::mrssGetEnclosures(const QDomElement& msg_element) c
QString url = elem_content.attribute(QSL("url")); QString url = elem_content.attribute(QSL("url"));
if (!url.isEmpty()) { if (!url.isEmpty()) {
enclosures.append(Enclosure(url, QSL("image/png"))); enclosures.append(Enclosure(url, QSL(DEFAULT_ENCLOSURE_MIME_TYPE)));
} }
} }

View File

@ -73,6 +73,10 @@ Message RssParser::extractMessage(const QDomElement& msg_element, const QDateTim
} }
if (!elem_enclosure.isEmpty()) { if (!elem_enclosure.isEmpty()) {
if (elem_enclosure_type.isEmpty()) {
elem_enclosure_type = QSL(DEFAULT_ENCLOSURE_MIME_TYPE);
}
new_message.m_enclosures.append(Enclosure(elem_enclosure, elem_enclosure_type)); new_message.m_enclosures.append(Enclosure(elem_enclosure, elem_enclosure_type));
qDebugNN << LOGSEC_CORE qDebugNN << LOGSEC_CORE
<< "Found enclosure" << "Found enclosure"