2021-01-14 04:23:19 +08:00
|
|
|
/**
|
|
|
|
* https://tools.ietf.org/html/rfc5173
|
|
|
|
*/
|
|
|
|
|
|
|
|
(Sieve => {
|
|
|
|
|
2021-01-15 00:50:23 +08:00
|
|
|
const Grammar = Sieve.Grammar;
|
|
|
|
|
|
|
|
class Body extends Grammar.Test
|
2021-01-14 04:23:19 +08:00
|
|
|
{
|
|
|
|
constructor()
|
|
|
|
{
|
2021-01-15 00:50:23 +08:00
|
|
|
super('body');
|
2021-01-14 04:23:19 +08:00
|
|
|
this.body_transform = ''; // :raw, :content <string-list>, :text
|
2021-01-15 00:50:23 +08:00
|
|
|
this.key_list = new Grammar.StringList;
|
2021-01-14 04:23:19 +08:00
|
|
|
}
|
|
|
|
|
2021-01-15 07:14:45 +08:00
|
|
|
get require() { return 'body'; }
|
|
|
|
|
2021-01-14 04:23:19 +08:00
|
|
|
toString()
|
|
|
|
{
|
|
|
|
return 'body'
|
|
|
|
// + ' ' + this.comparator
|
|
|
|
+ ' ' + this.match_type
|
|
|
|
+ ' ' + this.body_transform
|
|
|
|
+ ' ' + this.key_list;
|
|
|
|
}
|
2021-01-15 00:50:23 +08:00
|
|
|
|
|
|
|
pushArguments(args)
|
|
|
|
{
|
|
|
|
args.forEach((arg, i) => {
|
2021-01-15 18:34:16 +08:00
|
|
|
if (':raw' === arg || ':text' === arg) {
|
2021-01-15 00:50:23 +08:00
|
|
|
this.body_transform = arg;
|
|
|
|
} else if (arg instanceof Grammar.StringList || arg instanceof Grammar.StringType) {
|
2021-01-15 18:34:16 +08:00
|
|
|
if (':content' === args[i-1]) {
|
2021-01-15 07:32:04 +08:00
|
|
|
this.body_transform = ':content ' + arg;
|
|
|
|
} else {
|
|
|
|
this[args[i+1] ? 'content_list' : 'key_list'] = arg;
|
|
|
|
}
|
2021-01-15 00:50:23 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 06:42:46 +08:00
|
|
|
Sieve.Commands.body = Body;
|
2021-01-14 04:23:19 +08:00
|
|
|
|
|
|
|
})(this.Sieve);
|
|
|
|
|