Fix Sieve QuotedString handling

This commit is contained in:
the-djmaze 2024-09-23 13:43:24 +02:00
parent 257d9201f6
commit 61c2eefec1
13 changed files with 185 additions and 104 deletions

View file

@ -4,7 +4,6 @@
import {
GrammarQuotedString,
GrammarString,
TestCommand
} from 'Sieve/Grammar';
@ -14,19 +13,22 @@ export class SpamTestTest extends TestCommand
{
super();
this.percent = false, // 0 - 100 else 0 - 10
this.value = new GrammarQuotedString;
this._value = new GrammarQuotedString;
}
// get require() { return this.percent ? 'spamtestplus' : 'spamtest'; }
get require() { return /:value|:count/.test(this.match_type) ? ['spamtestplus','relational'] : 'spamtestplus'; }
get value() { return this._value.value; }
set value(v) { this._value.value = v; }
toString()
{
return 'spamtest'
+ (this.percent ? ' :percent' : '')
+ (this.comparator ? ' :comparator ' + this.comparator : '')
+ ' ' + this.match_type
+ ' ' + this.value;
+ ' ' + this._value;
}
pushArguments(args)
@ -34,8 +36,8 @@ export class SpamTestTest extends TestCommand
args.forEach(arg => {
if (':percent' === arg) {
this.percent = true;
} else if (arg instanceof GrammarString) {
this.value = arg;
} else if (arg instanceof GrammarQuotedString) {
this._value = arg;
}
});
}
@ -46,24 +48,27 @@ export class VirusTestTest extends TestCommand
constructor()
{
super();
this.value = new GrammarQuotedString; // 1 - 5
this._value = new GrammarQuotedString; // 1 - 5
}
get require() { return /:value|:count/.test(this.match_type) ? ['virustest','relational'] : 'virustest'; }
get value() { return this._value.value; }
set value(v) { this._value.value = v; }
toString()
{
return 'virustest'
+ (this.comparator ? ' :comparator ' + this.comparator : '')
+ ' ' + this.match_type
+ ' ' + this.value;
+ ' ' + this._value;
}
pushArguments(args)
{
args.forEach(arg => {
if (arg instanceof GrammarString) {
this.value = arg;
if (arg instanceof GrammarQuotedString) {
this._value = arg;
}
});
}