roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.79k stars 1.62k forks source link

Rules with nested ifs are broken when saved #8011

Closed ezaquarii closed 3 years ago

ezaquarii commented 3 years ago

I have the following sieve script:

<some rules before nested-if rule>

if address :contains ["From"] "domain.net" { 
    if address :contains ["From"] "foo" {
        fileinto "Domain.Foo";
    } elsif header :contains "Subject" "bar" {
        fileinto "Domain.Bar";
    } else {
        fileinto "Domain";
    }
}

if header :contains "Subject" ["TAG"] {
    fileinto "Tagged";
}

if address :contains ["To", "Cc"] "someaddress@domain.net" { 
    fileinto "SomeAddress";
}

When the script is saved, the resulting sieve script is:

<some rules before nested-if rule>

fileinto "Tagged";

This seems to be a similar issue to https://github.com/roundcube/roundcubemail/issues/5540 where the proposal was to drop nested ifs rules on save. Something went wrong here as the rules are dropped, but rules following the dropped one are damaged and deleted as well.

I'd propose an alternative solution instead:

When a rule cannot be parsed to display it in the visual editor, display it as a text field with source code instead

Please at least warn the user that the editor could not load all the rules, as otherwise the user will save a damaged script. Blocking the visual editor until the script can be parsed correctly would also be beneficial.

alecpl commented 3 years ago

I don't like the alternative solution. Managesieve plugin is not a sieve editor. It is a simple interface not requiring knowledge about sieve syntax. So, it has some limitations. The same as we don't support "else" we do not support nesting. If you need all these features use the "Edit filter set" action.

The bug should be investigated, though.

alecpl commented 3 years ago

Fixed.