More improvements and fixes based on test scripts

This commit is contained in:
djmaze 2021-01-14 17:50:23 +01:00
parent 0aafce4214
commit 22964f1fde
6 changed files with 100 additions and 50 deletions

View file

@ -4,14 +4,17 @@
(Sieve => {
Sieve.Extensions.Body = class
const Grammar = Sieve.Grammar;
class Body extends Grammar.Test
{
constructor()
{
super('body');
this.comparator = 'i;ascii-casemap',
this.match_type = ':is',
this.body_transform = ''; // :raw, :content <string-list>, :text
this.key_list = new Sieve.Grammar.StringList;
this.key_list = new Grammar.StringList;
}
toString()
@ -22,7 +25,25 @@ Sieve.Extensions.Body = class
+ ' ' + this.body_transform
+ ' ' + this.key_list;
}
};
pushArguments(args)
{
args.forEach((arg, i) => {
if (':is' === arg || ':contains' === arg || ':matches' === arg) {
this.match_type = arg;
} else if (':raw' === arg || ':text' === arg) {
this.body_transform = arg;
} else if (':content' === arg) {
// string-list
} else if (arg instanceof Grammar.StringList || arg instanceof Grammar.StringType) {
this[args[i+1] ? 'content_list' : 'key_list'] = arg;
}
});
}
}
Sieve.Extensions.Body = Body;
})(this.Sieve);

View file

@ -1,30 +0,0 @@
/**
* https://tools.ietf.org/html/rfc5429#section-2.1
*/
(Sieve => {
Sieve.Extensions.Ereject = class
{
constructor()
{
this.reason = new Sieve.Grammar.QuotedString;
}
toString()
{
return 'ereject ' + this.reason;
}
get reason()
{
return this.reason.value;
}
set reason(value)
{
this.reason.value = value;
}
};
})(this.Sieve);

View file

@ -1,30 +1,80 @@
/**
* https://tools.ietf.org/html/rfc5429#section-2.2
* https://tools.ietf.org/html/rfc5429
*/
(Sieve => {
Sieve.Extensions.Reject = class
const Grammar = Sieve.Grammar;
/**
* https://tools.ietf.org/html/rfc5429#section-2.1
*/
class Ereject extends Grammar.Command
{
constructor()
{
this.reason = new Sieve.Grammar.QuotedString;
super('ereject');
this._reason = new Grammar.QuotedString;
}
toString()
{
return 'reject ' + this.reason;
return 'ereject ' + this._reason + ';';
}
get reason()
{
return this.reason.value;
return this._reason.value;
}
set reason(value)
{
this.reason.value = value;
this._reason.value = value;
}
};
pushArguments(args)
{
if (args[0] instanceof Grammar.StringType) {
this._reason = args[0];
}
}
}
/**
* https://tools.ietf.org/html/rfc5429#section-2.2
*/
class Reject extends Grammar.Command
{
constructor()
{
super('reject');
this._reason = new Grammar.QuotedString;
}
toString()
{
return 'reject ' + this._reason + ';';
}
get reason()
{
return this._reason.value;
}
set reason(value)
{
this._reason.value = value;
}
pushArguments(args)
{
if (args[0] instanceof Grammar.StringType) {
this._reason = args[0];
}
}
}
Sieve.Extensions.Ereject = Ereject;
Sieve.Extensions.Reject = Reject;
})(this.Sieve);

View file

@ -4,10 +4,11 @@
(Sieve => {
Sieve.Extensions.Vacation = class
class Vacation extends Sieve.Grammar.Command
{
constructor()
{
super('vacation');
this.arguments = {
':days' : new Sieve.Grammar.Number,
':subject' : new Sieve.Grammar.QuotedString,
@ -79,6 +80,8 @@ Sieve.Extensions.Vacation = class
}
}
*/
};
}
Sieve.Extensions.Vacation = Vacation;
})(this.Sieve);