mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-29 15:26:09 +00:00
More improvements and fixes based on test scripts
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -85,12 +85,10 @@ Sieve.parseScript = script => {
|
||||
if ('if' === value) {
|
||||
new_command = new Sieve.Commands.Conditional(value);
|
||||
} else if ('elsif' === value || 'else' === value) {
|
||||
(command instanceof Sieve.Commands.Conditional)
|
||||
|| error('Not after IF condition');
|
||||
// (prev_command instanceof Sieve.Commands.Conditional) || error('Not after IF condition');
|
||||
new_command = new Sieve.Commands.Conditional(value);
|
||||
} else if ('allof' === value || 'anyof' === value) {
|
||||
(command instanceof Sieve.Commands.Conditional)
|
||||
|| error('Test-list not in conditional');
|
||||
(command instanceof Sieve.Commands.Conditional) || error('Test-list not in conditional');
|
||||
new_command = new Sieve.Tests[className]();
|
||||
} else if (Sieve.Tests[className]) {
|
||||
// address / envelope / exists / header / not / size
|
||||
@@ -102,8 +100,15 @@ Sieve.parseScript = script => {
|
||||
// body / ereject / reject / imap4flags / vacation
|
||||
new_command = new Sieve.Extensions[className]();
|
||||
} else {
|
||||
error('Unknown command ' + value);
|
||||
// new_command = new Sieve.Grammar.Command(value);
|
||||
console.error('Unknown command: ' + value);
|
||||
if (command && (
|
||||
command instanceof Sieve.Commands.Conditional
|
||||
|| command instanceof Sieve.Tests.Not
|
||||
|| command.tests instanceof Sieve.Grammar.TestList)) {
|
||||
new_command = new Sieve.Grammar.Test(value);
|
||||
} else {
|
||||
new_command = new Sieve.Grammar.Command(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (new_command instanceof Sieve.Grammar.Test) {
|
||||
@@ -198,6 +203,7 @@ Sieve.parseScript = script => {
|
||||
case T_BLOCK_END:
|
||||
(command instanceof Sieve.Commands.Conditional) || error('Block end has no matching block start');
|
||||
levels.pop();
|
||||
// prev_command = command;
|
||||
command = levels.last();
|
||||
break;
|
||||
|
||||
|
||||
@@ -238,8 +238,8 @@ class True extends Test
|
||||
|
||||
Sieve.Tests = {
|
||||
Address: Address,
|
||||
AllOf: AllOf,
|
||||
AnyOf: AnyOf,
|
||||
Allof: AllOf,
|
||||
Anyof: AnyOf,
|
||||
Envelope: Envelope,
|
||||
Exists: Exists,
|
||||
False: False,
|
||||
|
||||
Reference in New Issue
Block a user