Commit 9fa73ad8 authored by Laurent Montel's avatar Laurent Montel 😁

Protect '\'

parent acb62ad6
......@@ -52,6 +52,11 @@ QString AutoCreateScriptUtil::quoteStr(QString str)
return str.replace(QLatin1String("\""), QStringLiteral("\\\""));
}
QString AutoCreateScriptUtil::protectSlash(QString str)
{
return str.replace(QLatin1Char('\\'), QStringLiteral("\\\\"));
}
QString AutoCreateScriptUtil::createList(const QStringList &lst, bool addSemiColon, bool protectSlash)
{
QString result;
......@@ -59,7 +64,7 @@ QString AutoCreateScriptUtil::createList(const QStringList &lst, bool addSemiCol
bool wasFirst = true;
for (QString str : lst) {
if (protectSlash) {
str = str.replace(QLatin1Char('\\'), QStringLiteral("\\\\"));
str = AutoCreateScriptUtil::protectSlash(str);
}
result += (wasFirst ? QString() : QStringLiteral(",")) + QStringLiteral(" \"%1\"").arg(quoteStr(str));
wasFirst = false;
......
......@@ -40,6 +40,7 @@ QString fixListValue(QString valueStr);
QString quoteStr(QString str);
void comboboxItemNotFound(const QString &searchItem, const QString &name, QString &error);
QString createFullWhatsThis(const QString &help, const QString &href);
QString protectSlash(QString str);
}
}
#endif // AUTOCREATESCRIPTUTIL_H
......@@ -105,7 +105,9 @@ bool SieveConditionHeader::setParamWidgetValue(const QDomElement &element, QWidg
headerType->setCode(e.text());
} else if (index == 1) {
QLineEdit *value = w->findChild<QLineEdit *>(QStringLiteral("value"));
value->setText(e.text().replace(QStringLiteral("\""), QStringLiteral("\\\"")));
QString st = AutoCreateScriptUtil::quoteStr(e.text());
st = AutoCreateScriptUtil::quoteStr(st);
value->setText(st);
} else {
tooManyArgument(tagName, index, 2, error);
qCDebug(LIBKSIEVE_LOG) << " SieveConditionHeader::setParamWidgetValue too many argument " << index;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment