abandon needless # separator for scripts!

This commit is contained in:
Martin Rotter 2022-01-17 14:31:23 +01:00
parent aa334a90ac
commit 66159f42a1
3 changed files with 48 additions and 7 deletions

View File

@ -160,6 +160,50 @@ QString TextFactory::capitalizeFirstLetter(const QString& sts) {
}
}
QStringList TextFactory::tokenizeProcessArguments(QStringView command) {
QStringList args;
QString tmp;
int quote_count = 0;
bool in_quote = false;
for (int i = 0; i < command.size(); ++i) {
if (command.at(i) == QL1C('"')) {
++quote_count;
if (quote_count == 3) {
quote_count = 0;
tmp += command.at(i);
}
continue;
}
if (quote_count) {
if (quote_count == 1) {
in_quote = !in_quote;
}
quote_count = 0;
}
if (!in_quote && command.at(i).isSpace()) {
if (!tmp.isEmpty()) {
args += tmp;
tmp.clear();
}
}
else {
tmp += command.at(i);
}
}
if (!tmp.isEmpty()) {
args += tmp;
}
return args;
}
QString TextFactory::shorten(const QString& input, int text_length_limit) {
if (input.size() > text_length_limit) {
return input.left(text_length_limit - ELLIPSIS_LENGTH) + QString(ELLIPSIS_LENGTH, QL1C('.'));

View File

@ -32,6 +32,7 @@ class TextFactory {
static QString decrypt(const QString& text, quint64 key = 0);
static QString newline();
static QString capitalizeFirstLetter(const QString& sts);
static QStringList tokenizeProcessArguments(QStringView args);
// Shortens input string according to given length limit.
static QString shorten(const QString& input, int text_length_limit = TEXT_TITLE_LIMIT);

View File

@ -25,6 +25,7 @@
#include "services/standard/rssparser.h"
#include "services/standard/standardserviceroot.h"
#include <QCommandLineParser>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
@ -506,14 +507,9 @@ void StandardFeed::setEncoding(const QString& encoding) {
}
QStringList StandardFeed::prepareExecutionLine(const QString& execution_line) {
auto split_exec = execution_line.split(QSL(EXECUTION_LINE_SEPARATOR),
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
Qt::SplitBehaviorFlags::SkipEmptyParts);
#else
QString::SplitBehavior::SkipEmptyParts);
#endif
auto args = TextFactory::tokenizeProcessArguments(execution_line);
return qApp->replaceDataUserDataFolderPlaceholder(split_exec);
return qApp->replaceDataUserDataFolderPlaceholder(args);
}
QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QString& working_directory,