mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Added rfc5183, rfc5229, rfc5260 and rfc5293
Make comparator and match_type available for all Test classes Signed-off-by: djmaze <djmaze@djmaze.lan>
This commit is contained in:
parent
3ce123b536
commit
3566f4a538
9 changed files with 325 additions and 14 deletions
103
dev/Sieve/Extensions/rfc5260.js
Normal file
103
dev/Sieve/Extensions/rfc5260.js
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* https://tools.ietf.org/html/rfc5260
|
||||
*/
|
||||
|
||||
(Sieve => {
|
||||
|
||||
const Grammar = Sieve.Grammar;
|
||||
|
||||
class DateTest extends Grammar.Test
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('date');
|
||||
this.zone = new Grammar.QuotedString;
|
||||
this.originalzone = false;
|
||||
this.header_name = new Grammar.QuotedString;
|
||||
this.date_part = new Grammar.QuotedString;
|
||||
this.key_list = new Grammar.StringList;
|
||||
// rfc5260#section-6
|
||||
this.index = new Grammar.Number;
|
||||
this.last = false;
|
||||
}
|
||||
|
||||
// get require() { return ['date','index']; }
|
||||
get require() { return 'date'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'date'
|
||||
+ (this.last ? ' :last' : (this.index.value ? ' :index ' + this.index : ''))
|
||||
+ (this.originalzone ? ' :originalzone' : (this.zone.length ? ' :zone ' + this.zone : ''))
|
||||
// + ' ' + this.comparator
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.header_name
|
||||
+ ' ' + this.date_part
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
let l = args.length - 1;
|
||||
args.forEach((arg, i) => {
|
||||
if (':originalzone' === arg) {
|
||||
this.originalzone = true;
|
||||
} else if (':last' === arg) {
|
||||
this.last = true;
|
||||
} else if (':zone' === args[i-1]) {
|
||||
this.zone.value = arg.value;
|
||||
} else if (':index' === args[i-1]) {
|
||||
this.index.value = arg.value;
|
||||
} else if (l-2 === i) {
|
||||
this.header_name = arg;
|
||||
} else if (l-1 === i) {
|
||||
this.date_part = arg;
|
||||
} else if (l === i) {
|
||||
this.key_list = arg;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class CurrentDate extends Grammar.Test
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('date');
|
||||
this.zone = new Grammar.QuotedString;
|
||||
this.date_part = new Grammar.QuotedString;
|
||||
this.key_list = new Grammar.StringList;
|
||||
}
|
||||
|
||||
get require() { return 'date'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'date'
|
||||
+ (this.zone.length ? ' :zone ' + this.zone : '')
|
||||
// + ' ' + this.comparator
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.date_part
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
let l = args.length - 1;
|
||||
args.forEach((arg, i) => {
|
||||
if (':zone' === args[i-1]) {
|
||||
this.zone.value = arg.value;
|
||||
} else if (l-1 === i) {
|
||||
this.date_part = arg;
|
||||
} else if (l === i) {
|
||||
this.key_list = arg;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Sieve.Commands.date = DateTest;
|
||||
Sieve.Commands.currentdate = CurrentDate;
|
||||
|
||||
})(this.Sieve);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue