Commit 5cf4793a authored by Laurent Montel's avatar Laurent Montel 😁

Fix indent when we have complex script

parent e5f727f5
require "foreverypart";
require "reject";
require "subaddress";
require "fileinto";
require "imap4flags";
#SCRIPTNAME: Script part 0
# Sieve filter
# Declare the extensions used by this script.
#
# Messages bigger than 100K will be rejected with an error message
#
foreverypart :name "foo" {
if size :over 100K
{
reject text:
I'm sorry, I do not accept mail over 100kb in size.
Please upload larger files to a server and send me a link.
Thanks.
.
;
} elsif address :all :is [ "From", "To" ] "mailinglist@blafasel.invalid"
{
fileinto "INBOX.mailinglist";
} elsif anyof (not address :all :contains [ "To", "Cc", "Bcc" ] "me@blafasel.invalid"
, header :matches "Subject" [ "*money*", "*Viagra*" ]
)
{
fileinto "INBOX.spam";
break;
} else {
keep;
}
}
require "reject";
require "subaddress";
require "fileinto";
require "imap4flags";
#SCRIPTNAME: Script part 0
# Sieve filter
# Declare the extensions used by this script.
#
# Messages bigger than 100K will be rejected with an error message
#
foreverypart :name "foo" {
if size :over 100K
{
reject text:
I'm sorry, I do not accept mail over 100kb in size.
Please upload larger files to a server and send me a link.
Thanks.
.
;
} elsif address :all :is [ "From", "To" ] "mailinglist@blafasel.invalid"
{
fileinto "INBOX.mailinglist";
} elsif anyof (not address :all :contains [ "To", "Cc", "Bcc" ] "me@blafasel.invalid"
, header :matches "Subject" [ "*money*", "*Viagra*" ]
)
{
fileinto "INBOX.spam";
break;
} else {
keep;
}
}
......@@ -170,7 +170,10 @@ void SieveEditorGraphicalModeWidgetTest::shouldLoadScripts_data()
QTest::newRow("notify-2") << QStringLiteral("notify-2") << false << true;
//Need to fix it
QTest::newRow("foreverypart") << QStringLiteral("foreverypart") << true << true;
QTest::newRow("test-foreverypart-complex") << QStringLiteral("test-foreverypart-complex") << false << true;
}
QTEST_MAIN(SieveEditorGraphicalModeWidgetTest)
......@@ -183,7 +183,7 @@ void SieveScriptBlockWidget::generatedScript(QString &script, QStringList &requi
onlyActions = true;
//Just actions type
} else if (pageType() == BlockElse) {
script += indentation + QLatin1String("else {\n");
script += QLatin1String("else {\n");
} else {
QString conditionStr;
int numberOfCondition = 0;
......@@ -193,7 +193,7 @@ void SieveScriptBlockWidget::generatedScript(QString &script, QStringList &requi
QString blockStr;
switch (pageType()) {
case BlockIf:
blockStr = QStringLiteral("if ");
blockStr = indentation + QStringLiteral("if ");
break;
case BlockElsIf:
blockStr = QStringLiteral("elsif ");
......@@ -216,7 +216,7 @@ void SieveScriptBlockWidget::generatedScript(QString &script, QStringList &requi
if (conditionStr.isEmpty()) {
return;
} else {
script += indentation + filterStr + conditionStr;
script += filterStr + conditionStr;
}
if (hasUniqCondition) {
script += indentation + QLatin1String("{\n");
......
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