tonioo / sievelib

Client-side Sieve and Managesieve library written in Python.
MIT License
46 stars 24 forks source link

Parsing bug on anyof and allof #69

Closed Seemone closed 6 years ago

Seemone commented 6 years ago

this filter

require ["fileinto", "reject"];

if allof (not allof (address :is ["From","sender"] ["test1@test2.priv","test2@test2.priv"], header :matches "Subject" "INACTIVE*"), address :is "From" "user3@test3.priv")
{
 reject;
}

gets parsed and reconverted to sieve as

require ["fileinto", "reject"];
if allof (not allof (address :is ["From", "sender"] ["test1@test2.priv", "test2@test2.priv"], header :matches "Subject" "INACTIVE*")) {
    reject;
}

thus losing address :is "From" "user3@test3.priv"

Seemone commented 6 years ago

it seems triggered by the not before the allof.

Seemone commented 6 years ago

a "not allof" or a "not anyof" eats up the following test at the same level:

require ["fileinto", "reject"];
if anyof(not allof (size :over 200K, size :over 500K, size :under 10K), true, false)
{
 reject;
}

is parsed and re-converted into

require ["fileinto", "reject"];
if anyof (not allof (size :over 200K, size :over 500K, size :under 10K), false) {
    reject;
}

a "not" before a simple test behaves correctly:

require         ["fileinto", "reject"];

if anyof(        allof (size :over 200K, not size :over 500K, size :under 10K), true, false)
{
 reject;
}

is correctly parsed and rebuilt into

require ["fileinto", "reject"];
if anyof (allof (size :over 200K, not size :over 500K, size :under 10K), true, false) {
    reject;
}
tonioo commented 6 years ago

@Seemone Thank you for the debug, it should be fixed soon :)