mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Support Sieve RFC3894
This commit is contained in:
parent
8761b860fd
commit
219589b8ea
4 changed files with 30 additions and 11 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
* https://tools.ietf.org/html/rfc5228#section-2.9
|
* https://tools.ietf.org/html/rfc5228#section-2.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { capa } from 'Sieve/Utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
GrammarCommand,
|
GrammarCommand,
|
||||||
GrammarString,
|
GrammarString,
|
||||||
|
|
@ -102,11 +104,13 @@ export class FileIntoCommand extends GrammarCommand
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
|
return 'fileinto '
|
||||||
// https://datatracker.ietf.org/doc/html/rfc3894
|
// https://datatracker.ietf.org/doc/html/rfc3894
|
||||||
// :copy
|
+ ((this.copy && capa.includes('copy')) ? ':copy ' : '')
|
||||||
// https://datatracker.ietf.org/doc/html/rfc5490#section-3.2
|
// https://datatracker.ietf.org/doc/html/rfc5490#section-3.2
|
||||||
// :create
|
+ ((this.create && capa.includes('mailbox')) ? ':create ' : '')
|
||||||
return 'fileinto ' + this._mailbox + ';';
|
+ this._mailbox
|
||||||
|
+ ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
get mailbox()
|
get mailbox()
|
||||||
|
|
@ -141,9 +145,11 @@ export class RedirectCommand extends GrammarCommand
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
|
return 'redirect '
|
||||||
// https://datatracker.ietf.org/doc/html/rfc3894
|
// https://datatracker.ietf.org/doc/html/rfc3894
|
||||||
// :copy
|
+ ((this.copy && capa.includes('copy')) ? ':copy ' : '')
|
||||||
return 'redirect ' + this._address + ';';
|
+ this._address
|
||||||
|
+ ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
get address()
|
get address()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
* https://tools.ietf.org/html/rfc5228#section-8
|
* https://tools.ietf.org/html/rfc5228#section-8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { capa, forEachObjectEntry } from 'Sieve/Utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BRACKET_COMMENT,
|
BRACKET_COMMENT,
|
||||||
HASH_COMMENT,
|
HASH_COMMENT,
|
||||||
|
|
@ -84,7 +86,7 @@ import {
|
||||||
} from 'Sieve/Extensions/rfc6609';
|
} from 'Sieve/Extensions/rfc6609';
|
||||||
|
|
||||||
const
|
const
|
||||||
Commands = {
|
AllCommands = {
|
||||||
// Control commands
|
// Control commands
|
||||||
if: IfCommand,
|
if: IfCommand,
|
||||||
elsif: ElsIfCommand,
|
elsif: ElsIfCommand,
|
||||||
|
|
@ -182,6 +184,17 @@ const
|
||||||
export const parseScript = (script, name = 'script.sieve') => {
|
export const parseScript = (script, name = 'script.sieve') => {
|
||||||
script = script.replace(/\r?\n/g, '\r\n');
|
script = script.replace(/\r?\n/g, '\r\n');
|
||||||
|
|
||||||
|
// Only activate available commands
|
||||||
|
const Commands = {};
|
||||||
|
forEachObjectEntry(AllCommands, (key, cmd) => {
|
||||||
|
const requires = (new cmd).require;
|
||||||
|
if (!requires
|
||||||
|
|| (Array.isArray(requires) ? requires : [requires]).every(string => capa.includes(string))
|
||||||
|
) {
|
||||||
|
Commands[key] = cmd;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let match,
|
let match,
|
||||||
line = 1,
|
line = 1,
|
||||||
tree = [],
|
tree = [],
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ https://www.iana.org/assignments/sieve-extensions/sieve-extensions.xhtml
|
||||||
|
|
||||||
- [ ] RFC2852 envelope-deliverby / redirect-deliverby
|
- [ ] RFC2852 envelope-deliverby / redirect-deliverby
|
||||||
- [ ] RFC3461 envelope-dsn / redirect-dsn
|
- [ ] RFC3461 envelope-dsn / redirect-dsn
|
||||||
- [ ] RFC3894 copy
|
- [x] RFC3894 copy
|
||||||
- [ ] RFC4790 comparator-*
|
- [ ] RFC4790 comparator-*
|
||||||
- [x] RFC5173 body
|
- [x] RFC5173 body
|
||||||
- [x] RFC5183 environment
|
- [x] RFC5183 environment
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
<b data-i18n="POPUPS_SIEVE_SCRIPT/CAPABILITY_LABEL"></b>:
|
<b data-i18n="POPUPS_SIEVE_SCRIPT/CAPABILITY_LABEL"></b>:
|
||||||
<span data-bind="text: $root.sieveCapabilities"></span>
|
<span data-bind="text: $root.sieveCapabilities"></span>
|
||||||
</pre>
|
</pre>
|
||||||
<textarea style="width:100%" data-bind="value: body, valueUpdate: 'input'"></textarea>
|
<textarea style="width:100%;height:60vh" data-bind="value: body, valueUpdate: 'input'"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-bind="visible: !$root.rawActive()">
|
<div data-bind="visible: !$root.rawActive()">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue