mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
Added: rfc5233
Activate: comparator Bugfix: StringList must use .toString() Bugfix: redirect command Bugfix: MultiLine
This commit is contained in:
parent
3566f4a538
commit
73e26d388a
12 changed files with 86 additions and 50 deletions
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
const Grammar = Sieve.Grammar,
|
||||
Test = Grammar.Test,
|
||||
StringList = Grammar.StringList;
|
||||
StringList = Grammar.StringList,
|
||||
|
||||
isAddressPart = tag => ':localpart' === tag || ':domain' === tag || ':all' === tag || isSubAddressPart(tag),
|
||||
// https://tools.ietf.org/html/rfc5233
|
||||
isSubAddressPart = tag => ':user' === tag || ':detail' === tag;
|
||||
|
||||
/**
|
||||
* https://tools.ietf.org/html/rfc5228#section-5.1
|
||||
|
|
@ -16,7 +20,7 @@ class Address extends Test
|
|||
constructor()
|
||||
{
|
||||
super('address');
|
||||
this.address_part = ':all'; // :localpart | :domain | :all
|
||||
this.address_part = ':all';
|
||||
this.header_list = new StringList;
|
||||
this.key_list = new StringList;
|
||||
// rfc5260#section-6
|
||||
|
|
@ -24,23 +28,28 @@ class Address extends Test
|
|||
// this.last = false;
|
||||
}
|
||||
|
||||
get require() { return this.last ? 'index' : ''; }
|
||||
get require() {
|
||||
let requires = [];
|
||||
isSubAddressPart(this.address_part) && requires.push('subaddress');
|
||||
(this.last || (this.index && this.index.value)) && requires.push('index');
|
||||
return requires;
|
||||
}
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'address'
|
||||
// + (this.last ? ' :last' : (this.index.value ? ' :index ' + this.index : ''))
|
||||
// + ' ' + this.comparator
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.address_part
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.header_list
|
||||
+ ' ' + this.key_list;
|
||||
+ ' ' + this.header_list.toString()
|
||||
+ ' ' + this.key_list.toString();
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
args.forEach((arg, i) => {
|
||||
if (':localpart' === arg || ':domain' === arg || ':all' === arg) {
|
||||
if (isAddressPart(arg)) {
|
||||
this.address_part = arg;
|
||||
} else if (':last' === arg) {
|
||||
this.last = true;
|
||||
|
|
@ -67,7 +76,7 @@ class AllOf extends Test
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'allof ' + this.tests;
|
||||
return 'allof ' + this.tests.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +93,7 @@ class AnyOf extends Test
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'anyof ' + this.tests;
|
||||
return 'anyof ' + this.tests.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,27 +105,27 @@ class Envelope extends Test
|
|||
constructor()
|
||||
{
|
||||
super('envelope');
|
||||
this.address_part = ':all'; // :localpart | :domain | :all
|
||||
this.address_part = ':all';
|
||||
this.envelope_part = new StringList;
|
||||
this.key_list = new StringList;
|
||||
}
|
||||
|
||||
get require() { return 'envelope'; }
|
||||
get require() { return isSubAddressPart(this.address_part) ? ['envelope','subaddress'] : 'envelope'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'envelope'
|
||||
// + ' ' + this.comparator
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.address_part
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.envelope_part
|
||||
+ ' ' + this.key_list;
|
||||
+ ' ' + this.envelope_part.toString()
|
||||
+ ' ' + this.key_list.toString();
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
args.forEach((arg, i) => {
|
||||
if (':localpart' === arg || ':domain' === arg || ':all' === arg) {
|
||||
if (isAddressPart(arg)) {
|
||||
this.address_part = arg;
|
||||
} else if (arg instanceof StringList || arg instanceof Grammar.StringType) {
|
||||
this[args[i+1] ? 'envelope_part' : 'key_list'] = arg;
|
||||
|
|
@ -139,7 +148,7 @@ class Exists extends Test
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'exists ' + this.header_names;
|
||||
return 'exists ' + this.header_names.toString();
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
@ -171,7 +180,7 @@ class Header extends Test
|
|||
constructor()
|
||||
{
|
||||
super('header');
|
||||
this.address_part = ':all'; // :localpart | :domain | :all
|
||||
this.address_part = ':all';
|
||||
this.header_names = new StringList;
|
||||
this.key_list = new StringList;
|
||||
// rfc5260#section-6
|
||||
|
|
@ -179,22 +188,27 @@ class Header extends Test
|
|||
// this.last = false;
|
||||
}
|
||||
|
||||
get require() { return this.last ? 'index' : ''; }
|
||||
get require() {
|
||||
let requires = [];
|
||||
isSubAddressPart(this.address_part) && requires.push('subaddress');
|
||||
(this.last || (this.index && this.index.value)) && requires.push('index');
|
||||
return requires;
|
||||
}
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'header'
|
||||
// + (this.last ? ' :last' : (this.index.value ? ' :index ' + this.index : ''))
|
||||
// + ' ' + this.comparator
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.header_names
|
||||
+ ' ' + this.key_list;
|
||||
+ ' ' + this.header_names.toString()
|
||||
+ ' ' + this.key_list.toString();
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
args.forEach((arg, i) => {
|
||||
if (':localpart' === arg || ':domain' === arg || ':all' === arg) {
|
||||
if (isAddressPart(arg)) {
|
||||
this.address_part = arg;
|
||||
} else if (':last' === arg) {
|
||||
this.last = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue