mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +03:00
Added Sieve parser code in master
This commit is contained in:
parent
e90e8a55ce
commit
f4cd25f8ad
21 changed files with 2126 additions and 8 deletions
106
dev/Sieve/Extensions/rfc5260.js
Normal file
106
dev/Sieve/Extensions/rfc5260.js
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* https://tools.ietf.org/html/rfc5260
|
||||
*/
|
||||
|
||||
import {
|
||||
GrammarNumber,
|
||||
GrammarQuotedString,
|
||||
GrammarStringList,
|
||||
GrammarTest
|
||||
} from 'Sieve/Grammar';
|
||||
|
||||
export class DateCommand extends GrammarTest
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this.zone = new GrammarQuotedString;
|
||||
this.originalzone = false;
|
||||
this.header_name = new GrammarQuotedString;
|
||||
this.date_part = new GrammarQuotedString;
|
||||
this.key_list = new GrammarStringList;
|
||||
// rfc5260#section-6
|
||||
this.index = new GrammarNumber;
|
||||
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 ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.header_name
|
||||
+ ' ' + this.date_part
|
||||
+ ' ' + this.key_list.toString();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class CurrentDateCommand extends GrammarTest
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('date');
|
||||
this.zone = new GrammarQuotedString;
|
||||
this.date_part = new GrammarQuotedString;
|
||||
this.key_list = new GrammarStringList;
|
||||
}
|
||||
|
||||
get require() { return 'date'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'date'
|
||||
+ (this.zone.length ? ' :zone ' + this.zone : '')
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.date_part
|
||||
+ ' ' + this.key_list.toString();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Object.assign(Sieve.Commands, {
|
||||
date: DateTestCommand,
|
||||
currentdate: CurrentDateCommand
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue