mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
added Sieve getMatchTypes() for easy valid match-types
This commit is contained in:
parent
e4bd24b4e8
commit
37bb9a9a97
3 changed files with 13 additions and 12 deletions
|
|
@ -9,9 +9,7 @@ import {
|
||||||
MULTILINE_DOTSTART
|
MULTILINE_DOTSTART
|
||||||
} from 'Sieve/RegEx';
|
} from 'Sieve/RegEx';
|
||||||
|
|
||||||
import {
|
import { arrayToString, getMatchTypes } from 'Sieve/Utils';
|
||||||
arrayToString
|
|
||||||
} from 'Sieve/Utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* abstract
|
* abstract
|
||||||
|
|
@ -240,12 +238,10 @@ export class GrammarTest
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
// https://datatracker.ietf.org/doc/html/rfc6134#section-2.3
|
// https://datatracker.ietf.org/doc/html/rfc6134#section-2.3
|
||||||
if (':list' == this.match_type && !capa.includes('extlists')) {
|
if (!getMatchTypes().includes(this.match_type)) {
|
||||||
throw 'Unsupported match-type ' + this.match_type;
|
throw 'Unsupported match-type ' + this.match_type;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return (this.identifier
|
return (this.identifier
|
||||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||||
+ (this.match_type ? ' ' + this.match_type : '')
|
+ (this.match_type ? ' ' + this.match_type : '')
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* https://tools.ietf.org/html/rfc5228#section-8
|
* https://tools.ietf.org/html/rfc5228#section-8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { capa } from 'Sieve/Utils';
|
import { capa, getMatchTypes } from 'Sieve/Utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BRACKET_COMMENT,
|
BRACKET_COMMENT,
|
||||||
|
|
@ -213,11 +213,7 @@ export const parseScript = (script, name = 'script.sieve') => {
|
||||||
pushArg = arg => {
|
pushArg = arg => {
|
||||||
command || error('Argument not part of command');
|
command || error('Argument not part of command');
|
||||||
let prev_arg = args[args.length-1];
|
let prev_arg = args[args.length-1];
|
||||||
/*
|
if (getMatchTypes(0).includes(arg)) {
|
||||||
// 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;
|
command.match_type = arg;
|
||||||
} else if (':value' === prev_arg || ':count' === prev_arg) {
|
} else if (':value' === prev_arg || ':count' === prev_arg) {
|
||||||
// Sieve relational [RFC5231] match types
|
// Sieve relational [RFC5231] match types
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,13 @@ export const
|
||||||
setError = text => {
|
setError = text => {
|
||||||
serverError(true);
|
serverError(true);
|
||||||
serverErrorDesc(text);
|
serverErrorDesc(text);
|
||||||
|
},
|
||||||
|
|
||||||
|
getMatchTypes = (validOnly = 1) => {
|
||||||
|
let result = [':is',':contains',':matches'];
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc6134#section-2.3
|
||||||
|
if (capa.includes('extlists') || !validOnly) {
|
||||||
|
result.push(':list');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue