Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 61c2eef

Browse files
author
the-djmaze
committed
Fix Sieve QuotedString handling
1 parent 257d920 commit 61c2eef

13 files changed

+184
-103
lines changed

dev/Sieve/Extensions/rfc5183.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,27 @@ export class EnvironmentTest extends TestCommand
1313
constructor()
1414
{
1515
super();
16-
this.name = new GrammarQuotedString;
16+
this._name = new GrammarQuotedString;
1717
this.key_list = new GrammarStringList;
1818
}
1919

20+
get name() { return this._name.value; }
21+
set name(v) { this._name.value = v; }
22+
2023
get require() { return 'environment'; }
2124

2225
toString()
2326
{
2427
return 'environment'
2528
+ (this.comparator ? ' :comparator ' + this.comparator : '')
2629
+ ' ' + this.match_type
27-
+ ' ' + this.name
30+
+ ' ' + this._name
2831
+ ' ' + this.key_list;
2932
}
3033

3134
pushArguments(args)
3235
{
3336
this.key_list = args.pop();
34-
this.name = args.pop();
37+
this._name = args.pop();
3538
}
3639
}

dev/Sieve/Extensions/rfc5229.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export class SetCommand extends ActionCommand
2121

2222
get require() { return 'variables'; }
2323

24+
get name() { return this._name.value; }
25+
set name(str) { this._name.value = str; }
26+
27+
get value() { return this._value.value; }
28+
set value(str) { this._value.value = str; }
29+
2430
toString()
2531
{
2632
return 'set'
@@ -29,12 +35,6 @@ export class SetCommand extends ActionCommand
2935
+ ' ' + this._value;
3036
}
3137

32-
get name() { return this._name.value; }
33-
set name(str) { this._name.value = str; }
34-
35-
get value() { return this._value.value; }
36-
set value(str) { this._value.value = str; }
37-
3838
pushArguments(args)
3939
{
4040
[':lower', ':upper', ':lowerfirst', ':upperfirst', ':quotewildcard', ':length'].forEach(modifier => {

dev/Sieve/Extensions/rfc5230.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ export class VacationCommand extends ActionCommand
3030
// get require() { return ['vacation','vacation-seconds']; }
3131
get require() { return 'vacation'; }
3232

33+
get days() { return this._days.value; }
34+
get seconds() { return this._seconds.value; }
35+
get subject() { return this._subject.value; }
36+
get from() { return this._from.value; }
37+
get handle() { return this._handle.value; }
38+
get reason() { return this._reason.value; }
39+
40+
set days(int) { this._days.value = int; }
41+
set seconds(int) { this._seconds.value = int; }
42+
set subject(str) { this._subject.value = str; }
43+
set from(str) { this._from.value = str; }
44+
set handle(str) { this._handle.value = str; }
45+
set reason(str) { this._reason.value = str; }
46+
3347
toString()
3448
{
3549
let result = 'vacation';
@@ -56,20 +70,6 @@ export class VacationCommand extends ActionCommand
5670
return result + ' ' + this._reason;
5771
}
5872

59-
get days() { return this._days.value; }
60-
get seconds() { return this._seconds.value; }
61-
get subject() { return this._subject.value; }
62-
get from() { return this._from.value; }
63-
get handle() { return this._handle.value; }
64-
get reason() { return this._reason.value; }
65-
66-
set days(int) { this._days.value = int; }
67-
set seconds(int) { this._seconds.value = int; }
68-
set subject(str) { this._subject.value = str; }
69-
set from(str) { this._from.value = str; }
70-
set handle(str) { this._handle.value = str; }
71-
set reason(str) { this._reason.value = str; }
72-
7373
pushArguments(args)
7474
{
7575
this._reason.value = args.pop().value; // GrammarQuotedString

dev/Sieve/Extensions/rfc5235.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import {
66
GrammarQuotedString,
7-
GrammarString,
87
TestCommand
98
} from 'Sieve/Grammar';
109

@@ -14,28 +13,31 @@ export class SpamTestTest extends TestCommand
1413
{
1514
super();
1615
this.percent = false, // 0 - 100 else 0 - 10
17-
this.value = new GrammarQuotedString;
16+
this._value = new GrammarQuotedString;
1817
}
1918

2019
// get require() { return this.percent ? 'spamtestplus' : 'spamtest'; }
2120
get require() { return /:value|:count/.test(this.match_type) ? ['spamtestplus','relational'] : 'spamtestplus'; }
2221

22+
get value() { return this._value.value; }
23+
set value(v) { this._value.value = v; }
24+
2325
toString()
2426
{
2527
return 'spamtest'
2628
+ (this.percent ? ' :percent' : '')
2729
+ (this.comparator ? ' :comparator ' + this.comparator : '')
2830
+ ' ' + this.match_type
29-
+ ' ' + this.value;
31+
+ ' ' + this._value;
3032
}
3133

3234
pushArguments(args)
3335
{
3436
args.forEach(arg => {
3537
if (':percent' === arg) {
3638
this.percent = true;
37-
} else if (arg instanceof GrammarString) {
38-
this.value = arg;
39+
} else if (arg instanceof GrammarQuotedString) {
40+
this._value = arg;
3941
}
4042
});
4143
}
@@ -46,24 +48,27 @@ export class VirusTestTest extends TestCommand
4648
constructor()
4749
{
4850
super();
49-
this.value = new GrammarQuotedString; // 1 - 5
51+
this._value = new GrammarQuotedString; // 1 - 5
5052
}
5153

5254
get require() { return /:value|:count/.test(this.match_type) ? ['virustest','relational'] : 'virustest'; }
5355

56+
get value() { return this._value.value; }
57+
set value(v) { this._value.value = v; }
58+
5459
toString()
5560
{
5661
return 'virustest'
5762
+ (this.comparator ? ' :comparator ' + this.comparator : '')
5863
+ ' ' + this.match_type
59-
+ ' ' + this.value;
64+
+ ' ' + this._value;
6065
}
6166

6267
pushArguments(args)
6368
{
6469
args.forEach(arg => {
65-
if (arg instanceof GrammarString) {
66-
this.value = arg;
70+
if (arg instanceof GrammarQuotedString) {
71+
this._value = arg;
6772
}
6873
});
6974
}

dev/Sieve/Extensions/rfc5260.js

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export class DateTest extends TestCommand
1414
constructor()
1515
{
1616
super();
17-
this.zone = new GrammarQuotedString;
17+
this._zone = new GrammarQuotedString;
1818
this.originalzone = false;
19-
this.header_name = new GrammarQuotedString;
20-
this.date_part = new GrammarQuotedString;
19+
this._header_name = new GrammarQuotedString;
20+
this._date_part = new GrammarQuotedString;
2121
this.key_list = new GrammarStringList;
2222
// rfc5260#section-6
2323
this.index = new GrammarNumber;
@@ -27,30 +27,39 @@ export class DateTest extends TestCommand
2727
// get require() { return ['date','index']; }
2828
get require() { return 'date'; }
2929

30+
get zone() { return this._zone.value; }
31+
set zone(v) { this._zone.value = v; }
32+
33+
get header_name() { return this._header_name.value; }
34+
set header_name(v) { this._header_name.value = v; }
35+
36+
get date_part() { return this._date_part.value; }
37+
set date_part(v) { this._date_part.value = v; }
38+
3039
toString()
3140
{
3241
return 'date'
3342
+ (this.last ? ' :last' : (this.index.value ? ' :index ' + this.index : ''))
34-
+ (this.originalzone ? ' :originalzone' : (this.zone.length ? ' :zone ' + this.zone : ''))
43+
+ (this.originalzone ? ' :originalzone' : (this._zone.length ? ' :zone ' + this._zone : ''))
3544
+ (this.comparator ? ' :comparator ' + this.comparator : '')
3645
+ ' ' + this.match_type
37-
+ ' ' + this.header_name
38-
+ ' ' + this.date_part
46+
+ ' ' + this._header_name
47+
+ ' ' + this._date_part
3948
+ ' ' + this.key_list;
4049
}
4150

4251
pushArguments(args)
4352
{
4453
this.key_list = args.pop();
45-
this.date_part = args.pop();
46-
this.header_name = args.pop();
54+
this._date_part = args.pop();
55+
this._header_name = args.pop();
4756
args.forEach((arg, i) => {
4857
if (':originalzone' === arg) {
4958
this.originalzone = true;
5059
} else if (':last' === arg) {
5160
this.last = true;
5261
} else if (i && ':zone' === args[i-1]) {
53-
this.zone.value = arg.value;
62+
this._zone.value = arg.value;
5463
} else if (i && ':index' === args[i-1]) {
5564
this.index.value = arg.value;
5665
}
@@ -63,30 +72,36 @@ export class CurrentDateTest extends TestCommand
6372
constructor()
6473
{
6574
super();
66-
this.zone = new GrammarQuotedString;
67-
this.date_part = new GrammarQuotedString;
75+
this._zone = new GrammarQuotedString;
76+
this._date_part = new GrammarQuotedString;
6877
this.key_list = new GrammarStringList;
6978
}
7079

7180
get require() { return 'date'; }
7281

82+
get zone() { return this._zone.value; }
83+
set zone(v) { this._zone.value = v; }
84+
85+
get date_part() { return this._date_part.value; }
86+
set date_part(v) { this._date_part.value = v; }
87+
7388
toString()
7489
{
7590
return 'currentdate'
76-
+ (this.zone.length ? ' :zone ' + this.zone : '')
91+
+ (this._zone.length ? ' :zone ' + this._zone : '')
7792
+ (this.comparator ? ' :comparator ' + this.comparator : '')
7893
+ ' ' + this.match_type
79-
+ ' ' + this.date_part
94+
+ ' ' + this._date_part
8095
+ ' ' + this.key_list;
8196
}
8297

8398
pushArguments(args)
8499
{
85100
this.key_list = args.pop();
86-
this.date_part = args.pop();
101+
this._date_part = args.pop();
87102
args.forEach((arg, i) => {
88103
if (i && ':zone' === args[i-1]) {
89-
this.zone.value = arg.value;
104+
this._zone.value = arg.value;
90105
}
91106
});
92107
}

dev/Sieve/Extensions/rfc5293.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,30 @@ export class AddHeaderCommand extends ActionCommand
1616
{
1717
super();
1818
this.last = false;
19-
this.field_name = new GrammarQuotedString;
20-
this.value = new GrammarQuotedString;
19+
this._field_name = new GrammarQuotedString;
20+
this._value = new GrammarQuotedString;
2121
}
2222

2323
get require() { return 'editheader'; }
2424

25+
get field_name() { return this._field_name.value; }
26+
set field_name(v) { this._field_name.value = v; }
27+
28+
get value() { return this._value.value; }
29+
set value(v) { this._value.value = v; }
30+
2531
toString()
2632
{
2733
return this.identifier
2834
+ (this.last ? ' :last' : '')
29-
+ ' ' + this.field_name
30-
+ ' ' + this.value + ';';
35+
+ ' ' + this._field_name
36+
+ ' ' + this._value + ';';
3137
}
3238

3339
pushArguments(args)
3440
{
35-
this.value = args.pop();
36-
this.field_name = args.pop();
41+
this._value = args.pop();
42+
this._field_name = args.pop();
3743
this.last = args.includes(':last');
3844
}
3945
}
@@ -47,19 +53,22 @@ export class DeleteHeaderCommand extends ActionCommand
4753
this.last = false;
4854
this.comparator = '',
4955
this.match_type = ':is',
50-
this.field_name = new GrammarQuotedString;
56+
this._field_name = new GrammarQuotedString;
5157
this.value_patterns = new GrammarStringList;
5258
}
5359

5460
get require() { return 'editheader'; }
5561

62+
get field_name() { return this._field_name.value; }
63+
set field_name(v) { this._field_name.value = v; }
64+
5665
toString()
5766
{
5867
return this.identifier
5968
+ (this.last ? ' :last' : (this.index.value ? ' :index ' + this.index : ''))
6069
+ (this.comparator ? ' :comparator ' + this.comparator : '')
6170
+ ' ' + this.match_type
62-
+ ' ' + this.field_name
71+
+ ' ' + this._field_name
6372
+ ' ' + this.value_patterns + ';';
6473
}
6574

@@ -76,10 +85,10 @@ export class DeleteHeaderCommand extends ActionCommand
7685
});
7786

7887
if (l && args[l-1] instanceof GrammarString) {
79-
this.field_name = args[l-1];
88+
this._field_name = args[l-1];
8089
this.value_patterns = args[l];
8190
} else {
82-
this.field_name = args[l];
91+
this._field_name = args[l];
8392
}
8493
}
8594
}

0 commit comments

Comments
 (0)