Skip to content

Commit

Permalink
couple of fixes for #1133 and working on other parsing things
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Oct 16, 2023
1 parent 9792895 commit fe72cd1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
11 changes: 7 additions & 4 deletions src/librssguard/miscellaneous/textfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,13 @@ QStringList TextFactory::tokenizeProcessArguments(const QString& command) {

case TokenState::InsideArgSpaced: {
switch (chr.unicode()) {
case u'\\':
// We found escaped!
state = TokenState::EscapedFromSpaced;
continue;
// NOTE: Probably disable escaping in spaced arguments to provide simpler UX?
/*
case u'\\':
// We found escaped!
state = TokenState::EscapedFromSpaced;
continue;
*/

case u' ':
// We need to end this argument.
Expand Down
4 changes: 4 additions & 0 deletions src/librssguard/services/standard/parsers/feedparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ FeedParser::FeedParser(QString data, bool is_xml)

FeedParser::~FeedParser() {}

QStringList FeedParser::discoverFeeds(const QUrl& url) const {
return {};
}

QString FeedParser::xmlMessageRawContents(const QDomElement& msg_element) const {
QString raw_contents;
QTextStream str(&raw_contents);
Expand Down
6 changes: 6 additions & 0 deletions src/librssguard/services/standard/parsers/feedparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ class FeedParser {
explicit FeedParser(QString data, bool is_xml = true);
virtual ~FeedParser();

// Returns list of absolute URLs of discovered feeds from provided base URL.
virtual QStringList discoverFeeds(const QUrl& url) const;

// Guesses feed.
virtual QPair<StandardFeed*, QList<IconLocation>> guessFeed(const QByteArray& content,
const QString& content_type) const = 0;

// Returns list of all messages from the feed.
virtual QList<Message> messages();

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result, bool export_icon
}

case RootItem::Kind::Feed: {
auto* child_feed = dynamic_cast<StandardFeed*>(child_item);
QDomElement outline_feed = opml_document.createElement("outline");
auto* child_feed = qobject_cast<StandardFeed*>(child_item);
QDomElement outline_feed = opml_document.createElement(QSL("outline"));

outline_feed.setAttribute(QSL("type"), QSL("rss"));
outline_feed.setAttribute(QSL("text"), child_feed->title());
Expand Down Expand Up @@ -157,6 +157,14 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result, bool export_icon
outline_feed.setAttribute(QSL("version"), QSL("JSON"));
break;

case StandardFeed::Type::Sitemap:
outline_feed.setAttribute(QSL("version"), QSL("Sitemap"));
break;

case StandardFeed::Type::SitemapIndex:
outline_feed.setAttribute(QSL("version"), QSL("SitemapIndex"));
break;

default:
break;
}
Expand All @@ -181,17 +189,27 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {

try {
if (feed_lookup.fetch_metadata_online) {
new_feed = StandardFeed::guessFeed(StandardFeed::SourceType::Url,
StandardFeed::SourceType source_type =
feed_lookup.custom_data.contains(QSL("sourceType"))
? feed_lookup.custom_data[QSL("sourceType")].value<StandardFeed::SourceType>()
: StandardFeed::SourceType::Url;

QString pp_script = !feed_lookup.custom_data[QSL("postProcessScript")].toString().isEmpty()
? feed_lookup.custom_data[QSL("postProcessScript")].toString()
: feed_lookup.post_process_script;

new_feed = StandardFeed::guessFeed(source_type,
feed_lookup.url,
feed_lookup.post_process_script,
pp_script,
NetworkFactory::NetworkAuthentication::NoAuthentication,
!feed_lookup.do_not_fetch_icons,
{},
{},
feed_lookup.custom_proxy);

new_feed->setSourceType(source_type);
new_feed->setSource(feed_lookup.url);
new_feed->setPostProcessScript(feed_lookup.post_process_script);
new_feed->setPostProcessScript(pp_script);

if (feed_lookup.do_not_fetch_titles) {
QString old_title = feed_lookup.custom_data[QSL("title")].toString();
Expand All @@ -216,6 +234,10 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
new_feed = new StandardFeed();

if (feed_lookup.custom_data.isEmpty()) {
// We assume these are "best-guess" defaults.
new_feed->setSourceType(StandardFeed::SourceType::Url);
new_feed->setType(StandardFeed::Type::Rss2X);

new_feed->setSource(feed_lookup.url);
new_feed->setTitle(feed_lookup.url);
new_feed->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
Expand Down

0 comments on commit fe72cd1

Please sign in to comment.