From 40adf992edcaea253d763d6e308a95bc02221f54 Mon Sep 17 00:00:00 2001
From: the-djmaze <>
Date: Sun, 13 Mar 2022 20:22:00 +0100
Subject: [PATCH] Activate more Sieve extensions and use parseScript when
saving script
---
dev/Sieve/Extensions/rfc5173.js | 2 --
dev/Sieve/Extensions/rfc5183.js | 2 --
dev/Sieve/Extensions/rfc5229.js | 7 -----
dev/Sieve/Extensions/rfc5235.js | 7 -----
dev/Sieve/Extensions/rfc5260.js | 10 ++-----
dev/Sieve/Extensions/rfc5293.js | 6 -----
dev/Sieve/Parser.js | 27 ++++++++++++++++---
dev/Sieve/View/Script.js | 12 +++++++--
.../Views/User/PopupsSieveScript.html | 4 ++-
9 files changed, 39 insertions(+), 38 deletions(-)
diff --git a/dev/Sieve/Extensions/rfc5173.js b/dev/Sieve/Extensions/rfc5173.js
index cdf098bb6..2cbefab87 100644
--- a/dev/Sieve/Extensions/rfc5173.js
+++ b/dev/Sieve/Extensions/rfc5173.js
@@ -43,5 +43,3 @@ export class BodyCommand extends GrammarTest
});
}
}
-
-//Sieve.Commands.body = BodyCommand;
diff --git a/dev/Sieve/Extensions/rfc5183.js b/dev/Sieve/Extensions/rfc5183.js
index 60107385f..eeb57d2e1 100644
--- a/dev/Sieve/Extensions/rfc5183.js
+++ b/dev/Sieve/Extensions/rfc5183.js
@@ -34,5 +34,3 @@ export class EnvironmentCommand extends GrammarTest
this.key_list = args[args.length-1];
}
}
-
-//Sieve.Commands.environment = EnvironmentCommand;
diff --git a/dev/Sieve/Extensions/rfc5229.js b/dev/Sieve/Extensions/rfc5229.js
index 3ebd14a6d..d29bd1707 100644
--- a/dev/Sieve/Extensions/rfc5229.js
+++ b/dev/Sieve/Extensions/rfc5229.js
@@ -69,10 +69,3 @@ export class StringCommand extends GrammarTest
this.key_list = args[args.length-1];
}
}
-
-/*
-Object.assign(Sieve.Commands, {
- set: SetCommand,
- string: StringCommand
-});
-*/
diff --git a/dev/Sieve/Extensions/rfc5235.js b/dev/Sieve/Extensions/rfc5235.js
index 3b1112eea..982da394c 100644
--- a/dev/Sieve/Extensions/rfc5235.js
+++ b/dev/Sieve/Extensions/rfc5235.js
@@ -68,10 +68,3 @@ export class VirusTestCommand extends GrammarTest
});
}
}
-
-/*
-Object.assign(Sieve.Commands, {
- spamtest: SpamTestCommand,
- virustest: VirusTestCommand
-});
-*/
diff --git a/dev/Sieve/Extensions/rfc5260.js b/dev/Sieve/Extensions/rfc5260.js
index d6bdcc571..9911cb1c4 100644
--- a/dev/Sieve/Extensions/rfc5260.js
+++ b/dev/Sieve/Extensions/rfc5260.js
@@ -66,7 +66,7 @@ export class CurrentDateCommand extends GrammarTest
{
constructor()
{
- super('date');
+ super();
this.zone = new GrammarQuotedString;
this.date_part = new GrammarQuotedString;
this.key_list = new GrammarStringList;
@@ -76,7 +76,7 @@ export class CurrentDateCommand extends GrammarTest
toString()
{
- return 'date'
+ return 'currentdate'
+ (this.zone.length ? ' :zone ' + this.zone : '')
+ (this.comparator ? ' :comparator ' + this.comparator : '')
+ ' ' + this.match_type
@@ -98,9 +98,3 @@ export class CurrentDateCommand extends GrammarTest
});
}
}
-
-/*
-Object.assign(Sieve.Commands, {
- date: DateTestCommand,
- currentdate: CurrentDateCommand
-*/
diff --git a/dev/Sieve/Extensions/rfc5293.js b/dev/Sieve/Extensions/rfc5293.js
index 34ea6989f..3f39fd9ab 100644
--- a/dev/Sieve/Extensions/rfc5293.js
+++ b/dev/Sieve/Extensions/rfc5293.js
@@ -83,9 +83,3 @@ export class DeleteHeaderCommand extends GrammarCommand
}
}
}
-/*
-Object.assign(Sieve.Commands, {
- addheader: AddHeaderCommand,
- deleteheader: DeleteHeaderCommand
-});
-*/
diff --git a/dev/Sieve/Parser.js b/dev/Sieve/Parser.js
index 0473e2949..729d00a01 100644
--- a/dev/Sieve/Parser.js
+++ b/dev/Sieve/Parser.js
@@ -51,9 +51,10 @@ import {
TrueCommand
} from 'Sieve/Tests';
-import {
- VacationCommand
-} from 'Sieve/Extensions/rfc5230';
+import { BodyCommand } from 'Sieve/Extensions/rfc5173';
+import { EnvironmentCommand } from 'Sieve/Extensions/rfc5183';
+import { SetCommand, StringCommand } from 'Sieve/Extensions/rfc5229';
+import { VacationCommand } from 'Sieve/Extensions/rfc5230';
import {
SetFlagCommand,
@@ -62,6 +63,10 @@ import {
HasFlagCommand
} from 'Sieve/Extensions/rfc5232';
+import { SpamTestCommand, VirusTestCommand } from 'Sieve/Extensions/rfc5235';
+import { DateCommand, CurrentDateCommand } from 'Sieve/Extensions/rfc5260';
+import { AddHeaderCommand, DeleteHeaderCommand } from 'Sieve/Extensions/rfc5293';
+
import {
ErejectCommand,
RejectCommand
@@ -97,6 +102,13 @@ const
not: NotCommand,
size: SizeCommand,
true: TrueCommand,
+ // rfc5173
+ body: BodyCommand,
+ // rfc5183
+ environment: EnvironmentCommand,
+ // rfc5229
+ set: SetCommand,
+ string: StringCommand,
// rfc5230
vacation: VacationCommand,
// rfc5232
@@ -104,6 +116,15 @@ const
addflag: AddFlagCommand,
removeflag: RemoveFlagCommand,
hasflag: HasFlagCommand,
+ // rfc5235
+ spamtest: SpamTestCommand,
+ virustest: VirusTestCommand,
+ // rfc5260
+ date: DateCommand,
+ currentdate: CurrentDateCommand,
+ // rfc5293
+ AddHeaderCommand,
+ DeleteHeaderCommand,
// rfc5429
ereject: ErejectCommand,
reject: RejectCommand,
diff --git a/dev/Sieve/View/Script.js b/dev/Sieve/View/Script.js
index cb597464f..71a755fd5 100644
--- a/dev/Sieve/View/Script.js
+++ b/dev/Sieve/View/Script.js
@@ -43,6 +43,9 @@ export class SieveScriptPopupView extends rl.pluginPopupView {
let self = this,
script = self.script();
if (!self.saving/* && script.hasChanges()*/) {
+ this.errorText('');
+ self.saveError(false);
+
if (!script.verify()) {
return;
}
@@ -52,9 +55,14 @@ export class SieveScriptPopupView extends rl.pluginPopupView {
return;
}
+ try {
+ parseScript(this.script().body());
+ } catch (e) {
+ this.errorText(e.message);
+ return;
+ }
+
self.saving = true;
- self.saveError(false);
- self.errorText('');
if (self.allowToggle()) {
script.body(script.filtersToRaw());
diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsSieveScript.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsSieveScript.html
index 5e0ff4579..821017588 100644
--- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsSieveScript.html
+++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsSieveScript.html
@@ -64,9 +64,11 @@
+
💾