From 74a67aabaf56a91bbab209c058b642a0197bc81e Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 22 Sep 2024 16:36:12 +0200 Subject: [PATCH] Added some draft templates for Sieve GUI --- dev/Sieve/Commands.js | 2 - dev/Sieve/Commands/Actions.js | 12 +- dev/Sieve/Commands/Controls.js | 61 +++-- dev/Sieve/Commands/Tests.js | 5 - dev/Sieve/Extensions/rfc5230.js | 1 - dev/Sieve/Extensions/rfc5429.js | 8 +- dev/Sieve/Extensions/rfc5703.js | 11 +- dev/Sieve/Grammar.js | 100 ++++--- dev/Sieve/Parser.js | 10 +- dev/Sieve/README.md | 256 ++++++++++++++++++ dev/Sieve/Utils.js | 4 +- .../app/libraries/RainLoop/ServiceActions.php | 10 +- .../templates/Views/Sieve/AddressTest.html | 13 + .../app/templates/Views/Sieve/AllOfTest.html | 3 + .../app/templates/Views/Sieve/AnyOfTest.html | 3 + .../app/templates/Views/Sieve/BodyTest.html | 4 + .../Views/Sieve/CurrentDateTest.html | 5 + .../app/templates/Views/Sieve/DateTest.html | 9 + .../templates/Views/Sieve/ElsIfCommand.html | 9 + .../templates/Views/Sieve/ElseCommand.html | 5 + .../templates/Views/Sieve/EnvelopeTest.html | 9 + .../Views/Sieve/EnvironmentTest.html | 4 + .../app/templates/Views/Sieve/ExistsTest.html | 5 + .../Views/Sieve/FileIntoCommand.html | 5 + .../templates/Views/Sieve/HasFlagTest.html | 4 + .../app/templates/Views/Sieve/HeaderTest.html | 18 ++ .../app/templates/Views/Sieve/IHaveTest.html | 3 + .../app/templates/Views/Sieve/IfCommand.html | 8 + .../Views/Sieve/MailboxExistsTest.html | 3 + .../Views/Sieve/MetadataExistsTest.html | 4 + .../templates/Views/Sieve/MetadataTest.html | 5 + .../app/templates/Views/Sieve/NotTest.html | 3 + .../Sieve/NotifyMethodCapabilityTest.html | 5 + .../Views/Sieve/RedirectCommand.html | 5 + .../Views/Sieve/ServerMetadataExistsTest.html | 3 + .../Views/Sieve/ServerMetadataTest.html | 4 + .../app/templates/Views/Sieve/SizeTest.html | 7 + .../templates/Views/Sieve/SpamTestTest.html | 4 + .../app/templates/Views/Sieve/StringTest.html | 4 + .../Views/Sieve/ValidExtListTest.html | 3 + .../Views/Sieve/ValidNotifyMethodTest.html | 3 + .../templates/Views/Sieve/VirusTestTest.html | 3 + 42 files changed, 542 insertions(+), 101 deletions(-) create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/AddressTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/AnyOfTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/BodyTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/CurrentDateTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/DateTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/ElsIfCommand.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/ElseCommand.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/EnvelopeTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/EnvironmentTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/ExistsTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/FileIntoCommand.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/HasFlagTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/HeaderTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/IHaveTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/IfCommand.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/MailboxExistsTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataExistsTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/NotTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/NotifyMethodCapabilityTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/RedirectCommand.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/ServerMetadataExistsTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/ServerMetadataTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/SizeTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/SpamTestTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/StringTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/ValidExtListTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/ValidNotifyMethodTest.html create mode 100644 snappymail/v/0.0.0/app/templates/Views/Sieve/VirusTestTest.html diff --git a/dev/Sieve/Commands.js b/dev/Sieve/Commands.js index 45c2199c2..941b4e409 100644 --- a/dev/Sieve/Commands.js +++ b/dev/Sieve/Commands.js @@ -15,7 +15,6 @@ import { } from 'Sieve/Commands/Actions'; import { - ConditionalCommand, ElsIfCommand, ElseCommand, IfCommand, @@ -67,7 +66,6 @@ export const IfCommand, ElsIfCommand, ElseCommand, - ConditionalCommand, RequireCommand, StopCommand, // Action commands diff --git a/dev/Sieve/Commands/Actions.js b/dev/Sieve/Commands/Actions.js index 3d0665a7d..8d301ec0c 100644 --- a/dev/Sieve/Commands/Actions.js +++ b/dev/Sieve/Commands/Actions.js @@ -21,6 +21,10 @@ export class FileIntoCommand extends ActionCommand super(); // QuotedString / MultiLine this._mailbox = new GrammarQuotedString(); + // https://datatracker.ietf.org/doc/html/rfc3894 +// this.copy = false; + // https://datatracker.ietf.org/doc/html/rfc5490#section-3.2 +// this.create = false; } get require() { return 'fileinto'; } @@ -28,9 +32,7 @@ export class FileIntoCommand extends ActionCommand toString() { return 'fileinto' - // https://datatracker.ietf.org/doc/html/rfc3894 + ((this.copy && capa.includes('copy')) ? ' :copy' : '') - // https://datatracker.ietf.org/doc/html/rfc5490#section-3.2 + ((this.create && capa.includes('mailbox')) ? ' :create' : '') + ' ' + this._mailbox + ';'; @@ -64,15 +66,17 @@ export class RedirectCommand extends ActionCommand super(); // QuotedString / MultiLine this._address = new GrammarQuotedString(); + // https://datatracker.ietf.org/doc/html/rfc3894 +// this.copy = false; + // https://datatracker.ietf.org/doc/html/rfc6134#section-2.3 +// this.list = null; } toString() { return 'redirect' - // https://datatracker.ietf.org/doc/html/rfc6134#section-2.3 // + ((this.list && capa.includes('extlists')) ? ' :list ' + this.list : '') - // https://datatracker.ietf.org/doc/html/rfc3894 + ((this.copy && capa.includes('copy')) ? ' :copy' : '') + ' ' + this._address + ';'; diff --git a/dev/Sieve/Commands/Controls.js b/dev/Sieve/Commands/Controls.js index 20144d457..a82ed6f9a 100644 --- a/dev/Sieve/Commands/Controls.js +++ b/dev/Sieve/Commands/Controls.js @@ -5,6 +5,7 @@ import { ControlCommand, + GrammarCommands, GrammarStringList, GrammarQuotedString } from 'Sieve/Grammar'; @@ -16,37 +17,55 @@ import { * elsif * else */ -export class ConditionalCommand extends ControlCommand +export /*abstract*/ class ConditionalCommand extends ControlCommand { - constructor(identifier) + constructor() { - super(identifier); - this.test = null; - } - - toString() - { - return this.identifier + ' ' + this.test + ' ' + this.commands; - } /* - public function pushArguments(array $args): void - { - args.forEach((arg, i) => { - if (i && ':' === args[i-1][0]) { - this[args[i-1].replace(':','_')].value = arg.value; - } - }); - print_r($args); - exit; - } + if (this.constructor == ConditionalCommand) { + throw Error("Abstract class can't be instantiated."); + } */ + super(); + this.commands = new GrammarCommands; + } } export class IfCommand extends ConditionalCommand { + constructor() + { + super(); + this._test = null; // must be descendent instanceof TestCommand + } + + get test() + { + return this._test; + } + + set test(value) + { +/* + if (!value instanceof TestCommand) { + throw Error("test must be descendent instanceof TestCommand."); + } +*/ + this._test = value; + } + + toString() + { +/* + if (!this._test instanceof TestCommand) { + throw Error("test must be descendent instanceof TestCommand."); + } +*/ + return this.identifier + ' ' + this._test + ' ' + this.commands; + } } -export class ElsIfCommand extends ConditionalCommand +export class ElsIfCommand extends IfCommand { } diff --git a/dev/Sieve/Commands/Tests.js b/dev/Sieve/Commands/Tests.js index 15664220d..ef6ba50d7 100644 --- a/dev/Sieve/Commands/Tests.js +++ b/dev/Sieve/Commands/Tests.js @@ -316,11 +316,6 @@ export class NotTest extends TestCommand { return 'not ' + this.test; } - - pushArguments() - { - throw 'No arguments'; - } } /** diff --git a/dev/Sieve/Extensions/rfc5230.js b/dev/Sieve/Extensions/rfc5230.js index 1bc340236..9dd99e1e1 100644 --- a/dev/Sieve/Extensions/rfc5230.js +++ b/dev/Sieve/Extensions/rfc5230.js @@ -43,7 +43,6 @@ export class VacationCommand extends ActionCommand } if (this._from.length) { result += ' :from ' + this._from; -// result += ' :from ' + this.arguments[':from']; } if (this.addresses.length) { result += ' :addresses ' + this.addresses; diff --git a/dev/Sieve/Extensions/rfc5429.js b/dev/Sieve/Extensions/rfc5429.js index 984fa2eb9..d33aead7c 100644 --- a/dev/Sieve/Extensions/rfc5429.js +++ b/dev/Sieve/Extensions/rfc5429.js @@ -8,11 +8,11 @@ import { GrammarString } from 'Sieve/Grammar'; -class rfc5429Command extends ActionCommand +class /*abstract*/ rfc5429Command extends ActionCommand { - constructor(identifier) + constructor() { - super(identifier); + super(); this._reason = new GrammarQuotedString; } @@ -44,7 +44,6 @@ class rfc5429Command extends ActionCommand */ export class ErejectCommand extends rfc5429Command { - constructor() { super('ereject'); } get require() { return 'ereject'; } } @@ -53,6 +52,5 @@ export class ErejectCommand extends rfc5429Command */ export class RejectCommand extends rfc5429Command { - constructor() { super('reject'); } get require() { return 'reject'; } } diff --git a/dev/Sieve/Extensions/rfc5703.js b/dev/Sieve/Extensions/rfc5703.js index c0b5322e8..f131da33a 100644 --- a/dev/Sieve/Extensions/rfc5703.js +++ b/dev/Sieve/Extensions/rfc5703.js @@ -5,6 +5,7 @@ import { ActionCommand, ControlCommand, + GrammarCommands, GrammarNumber, GrammarQuotedString, GrammarString, @@ -20,6 +21,7 @@ export class ForEveryPartCommand extends ControlCommand { super(); this._name = new GrammarString; + this.commands = new GrammarCommands; } get require() { return 'foreverypart'; } @@ -27,7 +29,7 @@ export class ForEveryPartCommand extends ControlCommand toString() { let result = 'foreverypart'; - if (this._subject.length) { + if (this._name.length) { result += ' :name ' + this._name; } return result + ' ' + this.commands; @@ -43,12 +45,15 @@ export class ForEveryPartCommand extends ControlCommand } } +/** + * Must be inside foreverypart + */ export class BreakCommand extends ForEveryPartCommand { toString() { let result = 'break'; - if (this._subject.length) { + if (this._name.length) { result += ' :name ' + this._name; } return result + ';'; @@ -82,7 +87,6 @@ export class ReplaceCommand extends ActionCommand } if (this._from.length) { result += ' :from ' + this._from; -// result += ' :from ' + this.arguments[':from']; } return result + this.replacement + ';'; } @@ -140,6 +144,7 @@ export class EncloseCommand extends ActionCommand /** * https://datatracker.ietf.org/doc/html/rfc5703#section-7 + * Should be inside foreverypart, else empty and flagged as a compilation error */ export class ExtractTextCommand extends ActionCommand { diff --git a/dev/Sieve/Grammar.js b/dev/Sieve/Grammar.js index 95a142c11..e570966ba 100644 --- a/dev/Sieve/Grammar.js +++ b/dev/Sieve/Grammar.js @@ -52,34 +52,26 @@ export class GrammarComment extends GrammarString /** * https://tools.ietf.org/html/rfc5228#section-2.9 */ -export class GrammarCommand +const cmdNameSuffix = /(test|command|action)$/; +export /*abstract*/ class GrammarCommand { constructor(identifier) { - this.identifier = identifier || this.constructor.name.toLowerCase().replace(/(test|command|action)$/, ''); - this.arguments = []; - this.commands = new GrammarCommands; +/* + if (this.constructor == GrammarCommand) { + throw Error("Abstract class can't be instantiated."); + } +*/ + this.identifier = identifier || this.constructor.name.toLowerCase().replace(cmdNameSuffix, ''); } toString() { let result = this.identifier; - if (this.arguments.length) { + if (this.arguments?.length) { result += ' ' + arrayToString(this.arguments, ' '); } - return result + ( - this.commands.length ? ' ' + this.commands : ';' - ); - } - - getComparators() - { - return ['i;ascii-casemap']; - } - - getMatchTypes() - { - return [':is', ':contains', ':matches']; + return result + ';'; } pushArguments(args) @@ -108,63 +100,47 @@ export class GrammarCommands extends Array /** * https://tools.ietf.org/html/rfc5228#section-3 */ -export class ControlCommand extends GrammarCommand +export /*abstract*/ class ControlCommand extends GrammarCommand { +/* constructor(identifier) { - super(identifier); - this.commands = new GrammarCommands; - } - - toString() - { - let result = this.identifier; - if (this.arguments.length) { - result += ' ' + arrayToString(this.arguments, ' '); + if (this.constructor == ControlCommand) { + throw Error("Abstract class can't be instantiated."); } - return result + ( - this.commands.length ? ' ' + this.commands : ';' - ); - } - - getComparators() - { - return ['i;ascii-casemap']; - } - - getMatchTypes() - { - return [':is', ':contains', ':matches']; + super(identifier); } +*/ } /** * https://tools.ietf.org/html/rfc5228#section-4 */ -export class ActionCommand extends GrammarCommand +export /*abstract*/ class ActionCommand extends GrammarCommand { +/* constructor(identifier) { + if (this.constructor == ActionCommand) { + throw Error("Abstract class can't be instantiated."); + } super(identifier); } - - toString() - { - let result = this.identifier; - if (this.arguments.length) { - result += ' ' + arrayToString(this.arguments, ' '); - } - return result + ';' - } +*/ } /** * https://tools.ietf.org/html/rfc5228#section-5 */ -export class TestCommand extends GrammarCommand +export /*abstract*/ class TestCommand extends GrammarCommand { constructor(identifier) { +/* + if (this.constructor == TestCommand) { + throw Error("Abstract class can't be instantiated."); + } +*/ super(identifier); // Almost every test has a comparator and match_type, so define them here this.comparator = ''; @@ -324,3 +300,23 @@ GrammarMultiLine.fromString = string => { } return new GrammarMultiLine(); } + +export class UnknownCommand extends GrammarCommand +{ + constructor(identifier) + { + super(identifier); + this.commands = new GrammarCommands; + } + + toString() + { + let result = this.identifier; + if (this.arguments?.length) { + result += ' ' + arrayToString(this.arguments, ' '); + } + return result + ( + this.commands?.length ? ' ' + this.commands : ';' + ); + } +} diff --git a/dev/Sieve/Parser.js b/dev/Sieve/Parser.js index ce929d24e..467efc3bf 100644 --- a/dev/Sieve/Parser.js +++ b/dev/Sieve/Parser.js @@ -154,12 +154,10 @@ export const parseScript = (script, name = 'script.sieve') => { pushArgs(); value = value.toLowerCase(); let new_command; - if ('if' === value) { - new_command = new ConditionalCommand(value); - } else if ('elsif' === value || 'else' === value) { -// (prev_command instanceof ConditionalCommand) || error('Not after IF condition'); - new_command = new ConditionalCommand(value); - } else if (Commands[value]) { + if (Commands[value]) { + if ('elsif' === value || 'else' === value) { +// (prev_command instanceof ConditionalCommand) || error('Not after IF condition'); + } if ('allof' === value || 'anyof' === value) { // (command instanceof ConditionalCommand || command instanceof NotTest) || error('Test-list not in conditional'); } diff --git a/dev/Sieve/README.md b/dev/Sieve/README.md index 4b4849acb..2f802159b 100644 --- a/dev/Sieve/README.md +++ b/dev/Sieve/README.md @@ -31,3 +31,259 @@ https://www.iana.org/assignments/sieve-extensions/sieve-extensions.xhtml - [ ] RFC regex https://tools.ietf.org/html/draft-ietf-sieve-regex-01 - [ ] vnd.cyrus.* - [ ] vnd.dovecot.* + +# Classes + +## abstract GrammarCommand + identifier = identifier || constructor.name.toLowerCase().replace(/(test|command|action)$/, ''); + arguments = []; only initialized at pushArguments() + +### abstract ControlCommand extends GrammarCommand + +#### IncludeCommand extends ControlCommand + global = false; // ':personal' / ':global'; + once = false; + optional = false; + value = new GrammarQuotedString; + +#### ReturnCommand extends ControlCommand + no properties + +#### GlobalCommand extends ControlCommand + value = new GrammarStringList; + +#### ForEveryPartCommand extends ControlCommand + _name = new GrammarString; + commands = new GrammarCommands; + +#### ErrorCommand extends ControlCommand + message = new GrammarQuotedString; + +#### RequireCommand extends ControlCommand + capabilities = new GrammarStringList(); + +#### StopCommand extends ControlCommand + no properties + +#### abstract ConditionalCommand extends ControlCommand + no properties + +#### IfCommand extends ConditionalCommand + test = null; // must be descendent instanceof TestCommand + commands = new GrammarCommands; + +#### ElsIfCommand extends IfCommand + test = null; // must be descendent instanceof TestCommand + commands = new GrammarCommands; + +#### ElseCommand extends ConditionalCommand + no properties + commands = new GrammarCommands; + +### abstract ActionCommand extends GrammarCommand + +#### FileIntoCommand extends ActionCommand + _mailbox = new GrammarQuotedString(); + copy = false; + create = false; + +#### RedirectCommand extends ActionCommand + _address = new GrammarQuotedString(); + copy = false; + list = null; + +#### KeepCommand extends ActionCommand + no properties + +#### DiscardCommand extends ActionCommand + no properties + +#### SetCommand extends ActionCommand + modifiers = []; + _name = new GrammarQuotedString; + _value = new GrammarQuotedString; + +#### VacationCommand extends ActionCommand + _days = new GrammarNumber; + _seconds = new GrammarNumber; + _subject = new GrammarQuotedString; + _from = new GrammarQuotedString; + addresses = new GrammarStringList; + mime = false; + _handle = new GrammarQuotedString; + _reason = new GrammarQuotedString; // QuotedString / MultiLine + +#### SetFlagCommand extends ActionCommand + _variablename = new GrammarQuotedString; + list_of_flags = new GrammarStringList; + +#### AddFlagCommand extends ActionCommand + _variablename = new GrammarQuotedString; + list_of_flags = new GrammarStringList; + +#### RemoveFlagCommand extends ActionCommand + _variablename = new GrammarQuotedString; + list_of_flags = new GrammarStringList; + +#### AddHeaderCommand extends ActionCommand + last = false; + field_name = new GrammarQuotedString; + value = new GrammarQuotedString; + +#### DeleteHeaderCommand extends ActionCommand + index = new GrammarNumber; + last = false; + comparator = '', + match_type = ':is', + field_name = new GrammarQuotedString; + value_patterns = new GrammarStringList; + +#### ErejectCommand extends ActionCommand + _reason = new GrammarQuotedString; + +#### RejectCommand extends ActionCommand + _reason = new GrammarQuotedString; + +#### NotifyCommand extends ActionCommand + _method = new GrammarQuotedString; + _from = new GrammarQuotedString; + _importance = new GrammarNumber; + options = new GrammarStringList; + _message = new GrammarQuotedString; + +#### ReplaceCommand extends ActionCommand + mime = false; + _subject = new GrammarQuotedString; + _from = new GrammarQuotedString; + replacement = new GrammarQuotedString; + +#### EncloseCommand extends ActionCommand + _subject = new GrammarQuotedString; + headers = new GrammarStringList; + +#### ExtractTextCommand extends ActionCommand + modifiers = []; + _first = new GrammarNumber; + varname = new GrammarQuotedString; + +### abstract TestCommand extends GrammarCommand + +#### AddressTest extends TestCommand + address_part = ':all'; + header_list = new GrammarStringList; + key_list = new GrammarStringList; + index = new GrammarNumber; + last = false; +// mime +// anychild + +#### AllOfTest extends TestCommand + tests = new GrammarTestList; + +#### AnyOfTest extends TestCommand + tests = new GrammarTestList; + +#### EnvelopeTest extends TestCommand + address_part = ':all'; + envelope_part = new GrammarStringList; + key_list = new GrammarStringList; + +#### ExistsTest extends TestCommand + header_names = new GrammarStringList; +// mime +// anychild + +#### FalseTest extends TestCommand + +#### HeaderTest extends TestCommand + address_part = ':all'; + header_names = new GrammarStringList; + key_list = new GrammarStringList; + index = new GrammarNumber; + last = false; + mime = false; + anychild = false; + // when ":mime" is used: + type = false; + subtype = false; + contenttype = false; + param = new GrammarStringList; + +#### NotTest extends TestCommand + test = new TestCommand; + +#### SizeTest extends TestCommand + mode = ':over'; // :under + limit = 0; + +#### TrueTest extends TestCommand + +#### BodyTest extends TestCommand + body_transform = ''; // :raw, :content , :text + key_list = new GrammarStringList; + +#### EnvironmentTest extends TestCommand + name = new GrammarQuotedString; + key_list = new GrammarStringList; + +#### StringTest extends TestCommand + source = new GrammarStringList; + key_list = new GrammarStringList; + +#### HasFlagTest extends TestCommand + variable_list = new GrammarStringList; + list_of_flags = new GrammarStringList; + +#### SpamTestTest extends TestCommand + percent = false, // 0 - 100 else 0 - 10 + value = new GrammarQuotedString; + +#### VirusTestTest extends TestCommand + value = new GrammarQuotedString; // 1 - 5 + +#### DateTest extends TestCommand + zone = new GrammarQuotedString; + originalzone = false; + header_name = new GrammarQuotedString; + date_part = new GrammarQuotedString; + key_list = new GrammarStringList; + index = new GrammarNumber; + last = false; + +#### CurrentDateTest extends TestCommand + zone = new GrammarQuotedString; + date_part = new GrammarQuotedString; + key_list = new GrammarStringList; + +#### ValidNotifyMethodTest extends TestCommand + notification_uris = new GrammarStringList; + +#### NotifyMethodCapabilityTest extends TestCommand + notification_uri = new GrammarQuotedString; + notification_capability = new GrammarQuotedString; + key_list = new GrammarStringList; + +#### IHaveTest extends TestCommand + capabilities = new GrammarStringList; + +#### MailboxExistsTest extends TestCommand + mailbox_names = new GrammarStringList; + +#### MetadataTest extends TestCommand + mailbox = new GrammarQuotedString; + annotation_name = new GrammarQuotedString; + key_list = new GrammarStringList; + +#### MetadataExistsTest extends TestCommand + mailbox = new GrammarQuotedString; + annotation_names = new GrammarStringList; + +#### ServerMetadataTest extends TestCommand + annotation_name = new GrammarQuotedString; + key_list = new GrammarStringList; + +#### ServerMetadataExistsTest extends TestCommand + annotation_names = new GrammarStringList; + +#### ValidExtListTest extends TestCommand + ext_list_names = new GrammarStringList; diff --git a/dev/Sieve/Utils.js b/dev/Sieve/Utils.js index 14c58101a..266857aec 100644 --- a/dev/Sieve/Utils.js +++ b/dev/Sieve/Utils.js @@ -22,7 +22,7 @@ export const koComputable = fn => ko.computed(fn, {'pure':true}), arrayToString = (arr, separator) => - arr.map(item => item.toString?.() || item).join(separator), + (arr || []).map(item => item.toString?.() || item).join(separator), /* getNotificationMessage = code => { let key = getKeyByValue(Notifications, code); @@ -58,6 +58,8 @@ export const serverErrorDesc(text); }, + getComparators = () => ['i;ascii-casemap'], + getMatchTypes = (validOnly = 1) => { let result = [':is',':contains',':matches']; // https://datatracker.ietf.org/doc/html/rfc6134#section-2.3 diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php index 9b0ee7e23..034719aad 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php @@ -645,7 +645,15 @@ class ServiceActions $aTemplates[$sTemplateName] = $file; } } - +/* +// if (!$this->GetCapa(Capa::SIEVE, $oAccount)) { + if (!$bAdmin) { + foreach (\glob(APP_VERSION_ROOT_PATH."app/templates/Views/Sieve/*.html") as $file) { + $sTemplateName = 'Sieve' . \basename($file, '.html'); + $aTemplates[$sTemplateName] = $file; + } + } +*/ $this->oActions->Plugins()->CompileTemplate($aTemplates, $bAdmin); $sHtml = ''; diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/AddressTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/AddressTest.html new file mode 100644 index 000000000..370d806dc --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/AddressTest.html @@ -0,0 +1,13 @@ + +address + + + + + +// mime +// anychild diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html new file mode 100644 index 000000000..897692357 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/AllOfTest.html @@ -0,0 +1,3 @@ + +allof +
diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/AnyOfTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/AnyOfTest.html new file mode 100644 index 000000000..c82c46f14 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/AnyOfTest.html @@ -0,0 +1,3 @@ + +anyof +
diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/BodyTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/BodyTest.html new file mode 100644 index 000000000..acd28811d --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/BodyTest.html @@ -0,0 +1,4 @@ + +body + body_transform = ''; // :raw, :content , :text + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/CurrentDateTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/CurrentDateTest.html new file mode 100644 index 000000000..c5826ceb9 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/CurrentDateTest.html @@ -0,0 +1,5 @@ + +currentdate + + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/DateTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/DateTest.html new file mode 100644 index 000000000..c053cf56d --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/DateTest.html @@ -0,0 +1,9 @@ + +date + + + + + + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/ElsIfCommand.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/ElsIfCommand.html new file mode 100644 index 000000000..3f3f11bcf --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/ElsIfCommand.html @@ -0,0 +1,9 @@ + +elsif +
+ this.test +
+{ +
+} + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/ElseCommand.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/ElseCommand.html new file mode 100644 index 000000000..0ae441790 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/ElseCommand.html @@ -0,0 +1,5 @@ + +else +{ +
+} diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/EnvelopeTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/EnvelopeTest.html new file mode 100644 index 000000000..a3f9906df --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/EnvelopeTest.html @@ -0,0 +1,9 @@ + +envelope + + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/EnvironmentTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/EnvironmentTest.html new file mode 100644 index 000000000..e84bfd097 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/EnvironmentTest.html @@ -0,0 +1,4 @@ + +environment + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/ExistsTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/ExistsTest.html new file mode 100644 index 000000000..f34c4674c --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/ExistsTest.html @@ -0,0 +1,5 @@ + +exists + +// mime +// anychild diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/FileIntoCommand.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/FileIntoCommand.html new file mode 100644 index 000000000..73fd115fd --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/FileIntoCommand.html @@ -0,0 +1,5 @@ + +fileinto + + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/HasFlagTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/HasFlagTest.html new file mode 100644 index 000000000..6a98cade4 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/HasFlagTest.html @@ -0,0 +1,4 @@ + +hasflag + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/HeaderTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/HeaderTest.html new file mode 100644 index 000000000..40fdd8278 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/HeaderTest.html @@ -0,0 +1,18 @@ + +header + + + + + + + + + + + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/IHaveTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/IHaveTest.html new file mode 100644 index 000000000..cec46605d --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/IHaveTest.html @@ -0,0 +1,3 @@ + +ihave + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/IfCommand.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/IfCommand.html new file mode 100644 index 000000000..b8a132af3 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/IfCommand.html @@ -0,0 +1,8 @@ + +if +
+ this.test +
+{ +
+} diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/MailboxExistsTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/MailboxExistsTest.html new file mode 100644 index 000000000..396dc0e37 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/MailboxExistsTest.html @@ -0,0 +1,3 @@ + +mailboxexists + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataExistsTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataExistsTest.html new file mode 100644 index 000000000..45e028d96 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataExistsTest.html @@ -0,0 +1,4 @@ + +metadataexists + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataTest.html new file mode 100644 index 000000000..c43e92f55 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/MetadataTest.html @@ -0,0 +1,5 @@ + +metadata + + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/NotTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/NotTest.html new file mode 100644 index 000000000..d49c81c9e --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/NotTest.html @@ -0,0 +1,3 @@ + +not +
diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/NotifyMethodCapabilityTest.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/NotifyMethodCapabilityTest.html new file mode 100644 index 000000000..678185355 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/NotifyMethodCapabilityTest.html @@ -0,0 +1,5 @@ + +notifymethodcapability + + + diff --git a/snappymail/v/0.0.0/app/templates/Views/Sieve/RedirectCommand.html b/snappymail/v/0.0.0/app/templates/Views/Sieve/RedirectCommand.html new file mode 100644 index 000000000..bad195fb7 --- /dev/null +++ b/snappymail/v/0.0.0/app/templates/Views/Sieve/RedirectCommand.html @@ -0,0 +1,5 @@ + +redirect + +