Roundcube Community Forum

 

Sieverules (managesieve) plugin

Started by zoc, May 09, 2009, 05:35:25 AM

Previous topic - Next topic

JohnDoh

internalkernel and pela020 glad you got your problems sorted

user20100124: there is nothing done to what you enter in the UI, if you want to escape a character you have to do it yourself. altering a test string behind the scenes seems a little dangerous to me, for example how would I knoww when you want \\n or \n?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

user20100124

Example of a dovecot.sieve file:

------------------------------ snip ------------------------------
require ["regex"];

if allof (header :contains ["to", "cc"] "[email protected]",
        header :regex "Subject" "^\\[CentOS-announce\\] .* CentOS (2|3|4) .*")
{
        discard;
        stop;
}
------------------------------ snip ------------------------------

When loading a file like this one in the frontend i get the (correct) single slash I want ... saving is however not possible since there is a missing slash. If I use the advanced editor this is of course possible to fix ...


edit: i have *lots* of rules with regex and it does not only break the current one you are working at.

JohnDoh

ahh i see. check out the latest change in the repo. it should fix the disapearing slash.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

user20100124

The disappearing slash fix works fine - thanks. I found another bug:

With imapflags when editing a saved rule, the filter action "Mark message as" is not preselected (it's always Move message to, which is the first one).

JohnDoh

i cant recreate the problem with imapflags. make sure in your config you have imapflags set to true in sieverules_allowed_actions.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

user20100124

The action is enabled (I created the rule with sieverules):

------------------------------ snip ------------------------------
...
$rcmail_config['sieverules_allowed_actions'] = array(
   'fileinto' => TRUE,
   'vacation' => TRUE,
   'reject' => FALSE,
   'redirect' => FALSE,
   'keep' => TRUE,
   'discard' => TRUE,
   'imapflags' => TRUE,
   'notify' => FALSE,
   'stop' => TRUE
   );
...
------------------------------ snip ------------------------------

And a example file looks like this:

------------------------------ snip ------------------------------
## Generated by RoundCube Webmail SieveRules Plugin ##
require ["fileinto","imap4flags"];

# rule:[foo]
if allof (header :contains "X-List" "foo")
{
        fileinto "INBOX.foo";
        setflag "\\Seen";
        stop;
}
------------------------------ snip ------------------------------

JohnDoh

thanks for the examples. I have tied them with both the repo and released versions of the plugin and i cannot see any problem. sorry but i dont know what else to tell you.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

bjoh

I just recently installed your sieverules plugin and like it very much, so thanks a lot for it!

That said, I think I found a bug in the recent version (from 2010/01/29).

When I configure a new Spam rule in roundcube that tests if X-Spam-Score is >= 10, the following file is generated and then saved by the managesieve daemon:
## Generated by RoundCube Webmail SieveRules Plugin ##
require ["relational","comparator-i;ascii-numeric"];

# rule:[Spam]
if anyof (header :value \"ge\" :comparator "i;ascii-numeric" "X-Spam-Score" "10")
{
discard;
}


Notice the escaped \"ge\" comparator.
sievec throws an error when trying to compile the script, and sieverules itself seems not to be able to re-import the rule, as it just disappears when the Filters screen is reloaded.

The same happens with the "gt" comparator, possibly also others.

Can you reproduce this and if yes, could you tell me where to fix it?

Thank you!

JohnDoh

I can't reproduce it. It could be something to do with your PHP settings.

The values for the operators dropdown should be htmlencoded so lets check they are. Please goto the new/edit rule screen and view the source, search for `value &` and you should find them all, if you dont try searching for `value "` and see if that finds them.

If that is ok then double check you have magic_quotes_gpc turned off in your php config (should be done by default in the .htaccess file in the rc root).
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

bjoh

Quote from: JohnDoh;25274If that is ok then double check you have magic_quotes_gpc turned off in your php config (should be done by default in the .htaccess file in the rc root).

That was it - magic_quotes_gpc was turned on in apache2's php.ini. Now it works like a charm.

Thank you for your quick help!

Granada

Sieverules works quite fine, but I found an annoying misfeature in NetSieve.php. I know, this is not the sieverules author's concern, but maybe someone has a solution to it. We currently have three frontend machines handling the mailaccounts and NetSieve needs to follow the referrals it gets to e.g. mail1.server.net or mail2.server.net to login to the timsieved. Giving it the correct loginserver by hand it works perfectly, but otherwise I get the following error in the log:

[12-Feb-2010 11:10:22] Connection timed out (145):
[12-Feb-2010 11:10:22] Can't follow referral to mail2, The error was= Connection timed out (5):


google has only one answer that is not only five years old but also long solved inside NetSieve.php. But that did not fix my problem. Did any of you ran into this problem and could give me a hint?

Kind regards
Ruediger

JohnDoh

I'm not sure if it helps but since version 1.2 you can use %h instead of an actual hostname and then what ever imap host RC is connected too will be used.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

Granada

setting "sieverules_host" to %h does not solve the problem. But I got somewhat closer to a solution: editing Net_Sieve.php and inserting three new lines at the start of authPLAIN() makes it work:


    function _authPLAIN($user, $pass , $euser )
    {
        $this->_data['user']=$user;
        $this->_data['pass']=$pass;
        $this->_data['port']='2004';
        if ($euser != '') {
            $cmd=sprintf('AUTHENTICATE "PLAIN" "%s"', base64_encode($euser . chr(0) . $user . chr(0) . $pass ) ) ;
        } else {
            $cmd=sprintf('AUTHENTICATE "PLAIN" "%s"', base64_encode( chr(0) . $user . chr(0) . $pass ) );
        }
        return  $this->_sendCmd( $cmd ) ;
    }


This is the whole function authPLAIN(). The three new lines are the definitions of the array $this->_data[] with $user, $pass and port 2004. The problem seems to be that the first call of sendCmd is done with $user, $pass, $port and so on, but the second one when following the given referral (inside the function doCmd() ) it uses $this->data['host'], $this->data['user'] and so on. This array is unset at that very moment, so the connect fails.

It seems to be a bug in Net_Sieve.php that has never been discovered before since noone used the script to connect to a referred host. Maybe this once worked with PHP 4 when more global variable definitions were still common.

Kind regards
Ruediger

JohnDoh

I dont really want to branch from the stable version of Net:Sieve, i suggest you open a bug report here Net_Sieve
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

zelegolas

Hi

I installed sieverules plugin with RoundCube.
I can put some some rules but none of them are executed. :confused:

I have scrupulously followed the instructions in the README file as well as those provided in the wiki dovecot and sieve.

Someone has already had such problems?