summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-05-12 07:55:12 +0200
committerMontel Laurent <[email protected]>2017-05-12 07:55:12 +0200
commit9fa73ad8a94355c128821915907d0ec789db4dc3 (patch)
tree170c607861d9fc71a696d55f3fa16a948c79ece8
parentacb62ad6e369cd352bfd4b528255c9739766529c (diff)
Protect '\'
-rw-r--r--src/ksieveui/autocreatescripts/autocreatescriptutil.cpp7
-rw-r--r--src/ksieveui/autocreatescripts/autocreatescriptutil_p.h1
-rw-r--r--src/ksieveui/autocreatescripts/sieveconditions/sieveconditionheader.cpp4
3 files changed, 10 insertions, 2 deletions
diff --git a/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp b/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp
index c651a66..5fae5e3 100644
--- a/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp
+++ b/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp
@@ -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;
diff --git a/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h b/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h
index 051e266..2af7e2d 100644
--- a/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h
+++ b/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h
@@ -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
diff --git a/src/ksieveui/autocreatescripts/sieveconditions/sieveconditionheader.cpp b/src/ksieveui/autocreatescripts/sieveconditions/sieveconditionheader.cpp
index 1416777..d73e8db 100644
--- a/src/ksieveui/autocreatescripts/sieveconditions/sieveconditionheader.cpp
+++ b/src/ksieveui/autocreatescripts/sieveconditions/sieveconditionheader.cpp
@@ -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;