From eb369ca1222e099dbddff82a4381cb02cc9dd41f Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 15 Jan 2021 12:11:13 +0100 Subject: [PATCH] Added rfc6609 --- dev/Sieve/Extensions/rfc5230.js | 11 +++++- dev/Sieve/Extensions/rfc6609.js | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 dev/Sieve/Extensions/rfc6609.js diff --git a/dev/Sieve/Extensions/rfc5230.js b/dev/Sieve/Extensions/rfc5230.js index 9f75a5860..e6f7766df 100644 --- a/dev/Sieve/Extensions/rfc5230.js +++ b/dev/Sieve/Extensions/rfc5230.js @@ -1,5 +1,6 @@ /** * https://tools.ietf.org/html/rfc5230 + * https://tools.ietf.org/html/rfc6131 */ (Sieve => { @@ -12,6 +13,7 @@ class Vacation extends Grammar.Command { super('vacation'); this._days = new Grammar.Number; +// this._seconds = new Grammar.Number; this._subject = new Grammar.QuotedString; this._from = new Grammar.QuotedString; this.addresses = new Grammar.StringList; @@ -20,6 +22,7 @@ class Vacation extends Grammar.Command this._reason = new Grammar.QuotedString; // QuotedString / MultiLine } +// get require() { return ['vacation','vacation-seconds']; } get require() { return 'vacation'; } toString() @@ -27,6 +30,8 @@ class Vacation extends Grammar.Command let result = 'vacation'; if (0 < this._days.value) { result += ' :days ' + this._days; +// } else if (0 < this._seconds.value) { +// result += ' :seconds ' + this._seconds; } if (this._subject.length) { result += ' :subject ' + this._subject; @@ -46,14 +51,15 @@ class Vacation extends Grammar.Command return result + ' ' + this._reason; } - get days() { return this._days.value; } +// get seconds() { return this._seconds.value; } get subject() { return this._subject.value; } get from() { return this._from.value; } get handle() { return this._handle.value; } get reason() { return this._reason.value; } set days(int) { this._days.value = int; } +// set seconds(int) { this._seconds.value = int; } set subject(str) { this._subject.value = str; } set from(str) { this._from.value = str; } set handle(str) { this._handle.value = str; } @@ -70,6 +76,9 @@ class Vacation extends Grammar.Command case ':days': this._days.value = arg.value; // Grammar.Number break; +// case ':seconds': +// this._seconds.value = arg.value; // Grammar.Number +// break; case ':subject': this._subject.value = arg.value; // Grammar.QuotedString break; diff --git a/dev/Sieve/Extensions/rfc6609.js b/dev/Sieve/Extensions/rfc6609.js new file mode 100644 index 000000000..a78f8beb2 --- /dev/null +++ b/dev/Sieve/Extensions/rfc6609.js @@ -0,0 +1,63 @@ +/** + * https://tools.ietf.org/html/rfc6609 + */ + +(Sieve => { + +const Grammar = Sieve.Grammar; + +class Include extends Grammar.Command +{ + constructor() + { + super('include'); + this.global = false; // ':personal' / ':global'; + this.once = false; + this.optional = false; + this.value = new Grammar.QuotedString; + } + + get require() { return 'include'; } + + toString() + { + return this.identifier + + (this.global ? ' :global' : '') + + (this.once ? ' :once' : '') + + (this.optional ? ' :optional' : '') + + ' ' + this.value + ';'; + } + + pushArguments(args) + { + args.forEach(arg => { + if (':global' === arg || ':once' === arg || ':optional' === arg) { + this[arg.substr(1)] = true; + } else if (arg instanceof Grammar.QuotedString) { + this.value = arg; + } + }); + } +} + +class Return extends Grammar.Command +{ + constructor() + { + super('return'); + } + + get require() { return 'include'; } + + toString() + { + return 'return;'; + } +} + +Object.assign(Sieve.Commands, { + include: Include, + return: Return +}); + +})(this.Sieve);