abandon needless # separator for scripts!
This commit is contained in:
parent
aa334a90ac
commit
66159f42a1
@ -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) {
|
QString TextFactory::shorten(const QString& input, int text_length_limit) {
|
||||||
if (input.size() > text_length_limit) {
|
if (input.size() > text_length_limit) {
|
||||||
return input.left(text_length_limit - ELLIPSIS_LENGTH) + QString(ELLIPSIS_LENGTH, QL1C('.'));
|
return input.left(text_length_limit - ELLIPSIS_LENGTH) + QString(ELLIPSIS_LENGTH, QL1C('.'));
|
||||||
|
@ -32,6 +32,7 @@ class TextFactory {
|
|||||||
static QString decrypt(const QString& text, quint64 key = 0);
|
static QString decrypt(const QString& text, quint64 key = 0);
|
||||||
static QString newline();
|
static QString newline();
|
||||||
static QString capitalizeFirstLetter(const QString& sts);
|
static QString capitalizeFirstLetter(const QString& sts);
|
||||||
|
static QStringList tokenizeProcessArguments(QStringView args);
|
||||||
|
|
||||||
// Shortens input string according to given length limit.
|
// Shortens input string according to given length limit.
|
||||||
static QString shorten(const QString& input, int text_length_limit = TEXT_TITLE_LIMIT);
|
static QString shorten(const QString& input, int text_length_limit = TEXT_TITLE_LIMIT);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "services/standard/rssparser.h"
|
#include "services/standard/rssparser.h"
|
||||||
#include "services/standard/standardserviceroot.h"
|
#include "services/standard/standardserviceroot.h"
|
||||||
|
|
||||||
|
#include <QCommandLineParser>
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <QDomNode>
|
#include <QDomNode>
|
||||||
@ -506,14 +507,9 @@ void StandardFeed::setEncoding(const QString& encoding) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList StandardFeed::prepareExecutionLine(const QString& execution_line) {
|
QStringList StandardFeed::prepareExecutionLine(const QString& execution_line) {
|
||||||
auto split_exec = execution_line.split(QSL(EXECUTION_LINE_SEPARATOR),
|
auto args = TextFactory::tokenizeProcessArguments(execution_line);
|
||||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
|
||||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
|
||||||
#else
|
|
||||||
QString::SplitBehavior::SkipEmptyParts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return qApp->replaceDataUserDataFolderPlaceholder(split_exec);
|
return qApp->replaceDataUserDataFolderPlaceholder(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QString& working_directory,
|
QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QString& working_directory,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user