mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Added Sieve extension rfc6134 partial
This commit is contained in:
parent
63de537f8f
commit
e4bd24b4e8
13 changed files with 76 additions and 31 deletions
|
|
@ -73,7 +73,7 @@ export class RequireCommand extends GrammarCommand
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'require ' + this.capabilities.toString() + ';';
|
||||
return 'require ' + this.capabilities + ';';
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
@ -109,12 +109,12 @@ export class FileIntoCommand extends GrammarCommand
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'fileinto '
|
||||
return 'fileinto'
|
||||
// https://datatracker.ietf.org/doc/html/rfc3894
|
||||
+ ((this.copy && capa.includes('copy')) ? ':copy ' : '')
|
||||
+ ((this.copy && capa.includes('copy')) ? ' :copy' : '')
|
||||
// https://datatracker.ietf.org/doc/html/rfc5490#section-3.2
|
||||
+ ((this.create && capa.includes('mailbox')) ? ':create ' : '')
|
||||
+ this._mailbox
|
||||
+ ((this.create && capa.includes('mailbox')) ? ' :create' : '')
|
||||
+ ' ' + this._mailbox
|
||||
+ ';';
|
||||
}
|
||||
|
||||
|
|
@ -150,10 +150,13 @@ export class RedirectCommand extends GrammarCommand
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'redirect '
|
||||
|
||||
return 'redirect'
|
||||
// https://datatracker.ietf.org/doc/html/rfc6134#section-2.3
|
||||
// + ((this.list && capa.includes('extlists')) ? ' :list ' + this.list : '')
|
||||
// https://datatracker.ietf.org/doc/html/rfc3894
|
||||
+ ((this.copy && capa.includes('copy')) ? ':copy ' : '')
|
||||
+ this._address
|
||||
+ ((this.copy && capa.includes('copy')) ? ' :copy' : '')
|
||||
+ ' ' + this._address
|
||||
+ ';';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export class BodyTest extends GrammarTest
|
|||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.body_transform
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export class EnvironmentTest extends GrammarTest
|
|||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.name
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ export class StringTest extends GrammarTest
|
|||
return 'string'
|
||||
+ ' ' + this.match_type
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.source.toString()
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.source
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export class VacationCommand extends GrammarCommand
|
|||
// result += ' :from ' + this.arguments[':from'];
|
||||
}
|
||||
if (this.addresses.length) {
|
||||
result += ' :addresses ' + this.addresses.toString();
|
||||
result += ' :addresses ' + this.addresses;
|
||||
}
|
||||
if (this.mime) {
|
||||
result += ' :mime';
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class FlagCommand extends GrammarCommand
|
|||
|
||||
toString()
|
||||
{
|
||||
return this.identifier + ' ' + this._variablename + ' ' + this.list_of_flags.toString() + ';';
|
||||
return this.identifier + ' ' + this._variablename + ' ' + this.list_of_flags + ';';
|
||||
}
|
||||
|
||||
get variablename()
|
||||
|
|
@ -79,8 +79,8 @@ export class HasFlagTest extends GrammarTest
|
|||
return 'hasflag'
|
||||
+ ' ' + this.match_type
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.variable_list.toString()
|
||||
+ ' ' + this.list_of_flags.toString();
|
||||
+ ' ' + this.variable_list
|
||||
+ ' ' + this.list_of_flags;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export class DateTest extends GrammarTest
|
|||
+ ' ' + this.match_type
|
||||
+ ' ' + this.header_name
|
||||
+ ' ' + this.date_part
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
@ -77,7 +77,7 @@ export class CurrentDateTest extends GrammarTest
|
|||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.date_part
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export class MetadataTest extends GrammarTest
|
|||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.mailbox
|
||||
+ ' ' + this.annotation_name
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
@ -115,7 +115,7 @@ export class ServerMetadataTest extends GrammarTest
|
|||
+ ' ' + this.match_type
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.annotation_name
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
|
|||
32
dev/Sieve/Extensions/rfc6134.js
Normal file
32
dev/Sieve/Extensions/rfc6134.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* https://tools.ietf.org/html/rfc6134
|
||||
*/
|
||||
|
||||
import {
|
||||
GrammarStringList,
|
||||
GrammarTest
|
||||
} from 'Sieve/Grammar';
|
||||
|
||||
/**
|
||||
* https://datatracker.ietf.org/doc/html/rfc6134#section-2.7
|
||||
*/
|
||||
export class ValidExtListTest extends GrammarTest
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this.ext_list_names = new GrammarStringList;
|
||||
}
|
||||
|
||||
get require() { return 'foreverypart'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'valid_ext_list ' + this.ext_list_names;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
this.ext_list_names = args.pop();
|
||||
}
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ export class GrammarCommand
|
|||
result += ' ' + arrayToString(this.arguments, ' ');
|
||||
}
|
||||
return result + (
|
||||
this.commands.length ? ' ' + this.commands.toString() : ';'
|
||||
this.commands.length ? ' ' + this.commands : ';'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -240,6 +240,12 @@ export class GrammarTest
|
|||
|
||||
toString()
|
||||
{
|
||||
/*
|
||||
// https://datatracker.ietf.org/doc/html/rfc6134#section-2.3
|
||||
if (':list' == this.match_type && !capa.includes('extlists')) {
|
||||
throw 'Unsupported match-type ' + this.match_type;
|
||||
}
|
||||
*/
|
||||
return (this.identifier
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ (this.match_type ? ' ' + this.match_type : '')
|
||||
|
|
|
|||
|
|
@ -213,6 +213,10 @@ export const parseScript = (script, name = 'script.sieve') => {
|
|||
pushArg = arg => {
|
||||
command || error('Argument not part of command');
|
||||
let prev_arg = args[args.length-1];
|
||||
/*
|
||||
// https://datatracker.ietf.org/doc/html/rfc6134#section-2.3
|
||||
if (':is' === arg || ':contains' === arg || ':matches' === arg || (capa.includes('extlists') && ':list')) {
|
||||
*/
|
||||
if (':is' === arg || ':contains' === arg || ':matches' === arg) {
|
||||
command.match_type = arg;
|
||||
} else if (':value' === prev_arg || ':count' === prev_arg) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ https://www.iana.org/assignments/sieve-extensions/sieve-extensions.xhtml
|
|||
- [x] RFC5435 enotify
|
||||
- [x] RFC5463 ihave
|
||||
- [x] RFC5490 mailbox / mboxmetadata / servermetadata
|
||||
- [ ] RFC5703 enclose / extracttext / foreverypart / mime / replace
|
||||
- [x] RFC5703 enclose / extracttext / foreverypart / mime / replace
|
||||
- [x] RFC6131 vacation-seconds
|
||||
- [ ] RFC6134 extlists
|
||||
- [ ] RFC6558 convert
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ export class AddressTest extends GrammarTest
|
|||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.address_part
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.header_list.toString()
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.header_list
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
@ -108,7 +108,7 @@ export class AllOfTest extends GrammarTest
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'allof ' + this.tests.toString();
|
||||
return 'allof ' + this.tests;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ export class AnyOfTest extends GrammarTest
|
|||
|
||||
toString()
|
||||
{
|
||||
return 'anyof ' + this.tests.toString();
|
||||
return 'anyof ' + this.tests;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,8 +150,8 @@ export class EnvelopeTest extends GrammarTest
|
|||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.address_part
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.envelope_part.toString()
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.envelope_part
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
@ -195,7 +195,7 @@ export class ExistsTest extends GrammarTest
|
|||
result += ' :anychild';
|
||||
}
|
||||
}
|
||||
return result + ' ' + this.header_names.toString();
|
||||
return result + ' ' + this.header_names;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
@ -281,8 +281,8 @@ export class HeaderTest extends GrammarTest
|
|||
// + (this.last ? ' :last' : (this.index.value ? ' :index ' + this.index : ''))
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ ' ' + this.match_type
|
||||
+ ' ' + this.header_names.toString()
|
||||
+ ' ' + this.key_list.toString();
|
||||
+ ' ' + this.header_names
|
||||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue