From bade9b19e5062957438ae2935ef95cb653250b1a Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 19 Aug 2009 01:00:03 +0200 Subject: [PATCH] MFB: Correctly match negative header values with numeric comparison in Sieve driver (bb@apc.ag, Bug #7308). --- ingo/docs/CHANGES | 2 + ingo/lib/Script/Sieve.php | 31 +++++- ingo/locale/ca_ES/help.xml | 88 +++++++++++++++- ingo/locale/de_DE/help.xml | 6 +- ingo/locale/en_US/help.xml | 4 + ingo/locale/es_ES/help.xml | 114 +++++++++++++++++---- ingo/locale/fi_FI/help.xml | 82 ++++++++++++++- ingo/locale/fr_FR/help.xml | 88 +++++++++++++++- ingo/locale/lv_LV/help.xml | 249 +++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 635 insertions(+), 29 deletions(-) diff --git a/ingo/docs/CHANGES b/ingo/docs/CHANGES index 081a06292..653d4d337 100644 --- a/ingo/docs/CHANGES +++ b/ingo/docs/CHANGES @@ -10,6 +10,8 @@ v2.0-git v1.2.2-cvs ---------- +[jan] Correctly match negative header values with numeric comparison in Sieve + driver (bb@apc.ag, Bug #7308). [jan] Implement removeUserData API (adrieder@sbox.tugraz.at, Request #8452). [jan] Take default settings for forwards, vacation and spam rules from config/prefs.php in the SQL storage driver. diff --git a/ingo/lib/Script/Sieve.php b/ingo/lib/Script/Sieve.php index 6dd2fd90a..ea06a7a34 100644 --- a/ingo/lib/Script/Sieve.php +++ b/ingo/lib/Script/Sieve.php @@ -1669,13 +1669,36 @@ class Sieve_Test_Relational extends Sieve_Test { Ingo_Script_Sieve::escapeString($val) . '"'; } - $code .= $headerstr . "] "; + $code .= $headerstr . '] '; + $headerstr = '[' . $headerstr . ']'; } elseif ($header_count == 1) { $code .= '"' . Ingo_Script_Sieve::escapeString($headers[0]) . '" '; + $headerstr = Ingo_Script_Sieve::escapeString($headers[0]); + } + + $code .= '["' . $this->_vars['value'] . '"]'; + + // Add workarounds for negative numbers - works only if the comparison + // value is positive. Sieve doesn't support comparisons of negative + // numbers at all so this is the best we can do. + switch ($this->_vars['comparison']) { + case 'gt': + case 'ge': + case 'eq': + // Greater than, greater or equal, equal: number must be + // non-negative. + return 'allof ( not header :comparator "i;ascii-casemap" :contains "' + . $headerstr . '" "-", ' . $code . ' )'; + break; + case 'lt': + case 'le': + case 'ne': + // Less than, less or equal, nonequal: also match negative numbers + return 'anyof ( header :comparator "i;ascii-casemap" :contains "' + . $headerstr . '" "-", ' . $code . ' )'; + break; } - - return $code . '["' . $this->_vars['value'] . '"]'; - } + } /** * Checks if the rule parameters are valid. diff --git a/ingo/locale/ca_ES/help.xml b/ingo/locale/ca_ES/help.xml index bfb7a2ce4..ed13b7676 100755 --- a/ingo/locale/ca_ES/help.xml +++ b/ingo/locale/ca_ES/help.xml @@ -119,8 +119,14 @@ El missatge s'emmagatzemar You may specify marking a message with one or more IMAP flags as one of the actions in a rule. The possible values are Seen, Flagged For Followup, Answered, and Deleted. + --> - + Regla de filtrat: Coincidència A cada condició d'una regla hi ha tres components. El primer en el camp que cal examinar. El segon és el tipus de comparació a realitzar. El tercer és el valor amb el qual cal comparar el camp. Existeixen diversos tipus diferents de comparances realizables. Les comparances disponibles per a cada camp depenen tant del tipus de camp com del que pugui manejar el programari utilitzat. Per això no totes les següents possibles opcions de coincidència apareixeran en un camp determinat. @@ -197,7 +203,85 @@ Aquesta Aquesta és una prova relacional que compara numéricament el valor indicat i el valor de la capçalera del missatge. - + Regla de filtrat: Nom diff --git a/ingo/locale/de_DE/help.xml b/ingo/locale/de_DE/help.xml index 2d58108c8..4690bb08c 100644 --- a/ingo/locale/de_DE/help.xml +++ b/ingo/locale/de_DE/help.xml @@ -131,7 +131,7 @@ einer oder mehreren IMAP-Markierungen versehen wird. Die möglichen Markierungen sind Gelesen, Markiert zur Wiedervorlage, Beantwortet und Gelöscht. - + Filterregel: Bedingungen Jede Bedingung einer Filterregel besteht aus drei Komponenten. Die erste bestimmt das Feld der Nachricht, das überprüft werden soll. @@ -209,6 +209,10 @@ Größer als Dies ist ein Vergleichstest, der den angegebenen Wert und den Wert im Nachrichtenfeld numerisch vergleicht. + Einschränkung von Sieve-Filtern + Die Sieve-Spezifikation unterstützt keine Vergleichsoperationen mit + negativen Zahlen. Wenn Sie eine negative Zahl als Vergleichswert eingeben, + wird Ihre Regel nicht funktionieren. Filterregel: Regelname diff --git a/ingo/locale/en_US/help.xml b/ingo/locale/en_US/help.xml index 31ea11e81..df88445c6 100644 --- a/ingo/locale/en_US/help.xml +++ b/ingo/locale/en_US/help.xml @@ -189,6 +189,10 @@ Greater than This is a relational test which will compare the value you specify and the value in the message header numerically. + Limitation with Sieve filtering + The Sieve specification doesn't support comparions with negative + numbers. If you enter a negative value in one of the relational tests, + your rule won't work correctly. Filter Rule: Name diff --git a/ingo/locale/es_ES/help.xml b/ingo/locale/es_ES/help.xml index 358dcc25b..266bd5f6d 100644 --- a/ingo/locale/es_ES/help.xml +++ b/ingo/locale/es_ES/help.xml @@ -87,7 +87,7 @@ El mensaje original se eliminará y se enviará un mensaje nuevo al remitente con el texto que indique. - + Regla de filtrado: Combinar opciones Puede definir varias condiciones en una misma regla. Puede agruparlas de forma lógica mediante "Y"/"O", No puede crear filtros complejos que contengan ambos tipos de condiciones. @@ -101,13 +101,13 @@ Si seleccion O, las acciones indicadas se ejecutarán si se cumple al menso una de las condiciones. - + Regla de filtrado: Señalar mensaje Como una de las acciones de una regla, puede indicar que se señale un mensaje con uno o más de los marcadores IMAP. Los valores posibles son Continuación, Respondido y Eliminado. - + Regla de filtrado: Coincidencia En cada condición de una regla hay tres componentes. El primero en el campo que hay que examinar. El segundo es el tipo de comparación a realizar. El tercero es el valor con el que hay que comparar el campo. @@ -195,79 +195,157 @@ Ésta es una prueba relacional que compara numéricamente el valor indicado y el valor de la cabecera del mensaje. - - + + Regla de filtrado: Nombre Se trata de un nombre descriptivo de una regla. Puede usarlo para identificar una regla determinada en su listado de filtros. - + Regla de filtrado: Detener comprobación Si se activa esta opción y un mensaje cumple la regla, el resto de los mensajes no se procesarán. - + Ausencia Los mensajes de ausencia son respuestas automáticas enviadas a la gente que le envíe correo. Normalmente se utilizan cuando va a estar ausente por un largo periodo de tiempo. - + Vacation Period Vacation messages will only be sent during the period of time that you are on vacation. - + Ausencia: No responder a granel Activando esta opción las respuestas por ausencia no se enviarán con mensajes que parezcan proceder de listas de correo o que estén marcados como correo a granel. - + Ausencia: Intervalo de respuesta Es el número de días a esperar antes de volver a enviar una respuesta automática a una direcci que ya haya recibido una. - + Ausencia: Mis direcciones de correo Si tiene más de una dirección de correo asignadas a este buzón, indíquelas aquí. - + Ausencia: Sin respuestas No enviar la notificación de ausencia a estos destinatarios. Cada dirección debe estar en una línea distinta. - + Ausencia: Motivo de la ausencia Es el texto que se enviará en sus notificaciones de ausencia. - + Ausencia: Asunto de la ausencia Es el asunto que se utilizará en las notificaciones de ausencia. - + Lista blanca Lista blanca La lista blanca es un listado de direcciones (legítimas) de las que siempre desea poder ver los mensajes en el buzón de Entrada. Cada dirección debe incluirse en una línea distinta. - + Lista blanca: Direcciones PENDIENTE. Cada dirección debe incluirse en una línea distinta. - + Filtrado de Spam: Nivel de Spam El sistema considerará como spam los mensajes con una puntuación de spam mayor o igual al número introducido aquí. @@ -276,7 +354,7 @@ Números más reducidos interceptarán más mensajes con el inconveniente de que hay mayores posibilidades de interceptar mensajes reales. "5" es un valor típico si su sistema utiliza SpamAssassin. - + Filtrado de Spam: Carpeta en la que almacenar el spam El sistema archivará los mensajes determinados como spam en esta carpeta. diff --git a/ingo/locale/fi_FI/help.xml b/ingo/locale/fi_FI/help.xml index 2a400615e..cc4370831 100644 --- a/ingo/locale/fi_FI/help.xml +++ b/ingo/locale/fi_FI/help.xml @@ -113,7 +113,7 @@ Yhtenä toimintona voit valita viestin merkinnän, jolloin voit merkitä viestin yhdellä tai useammalla IMAP tilatiedolla. Käytettävissä on tilatiedot: Vanha, Tärkeä, Vastattu ja Poistettu. - + Suodatinsääntö: Täsmäys Jokainen suodatinsääntö koostuu kolmesta komponentista. Ensimmäinen on tutkittava kenttä. Toinen on vertailutapa. Kolmas on arvo johon kentää verrataan. @@ -191,7 +191,85 @@ Tämä vertaa antaamasi lukua ja viestin otsakkeissa olevaa lukuarvoa numeerisesti keskenään. - + Suodatinsääntö: Nimi diff --git a/ingo/locale/fr_FR/help.xml b/ingo/locale/fr_FR/help.xml index 5f1826982..cad19abf9 100644 --- a/ingo/locale/fr_FR/help.xml +++ b/ingo/locale/fr_FR/help.xml @@ -169,8 +169,14 @@ action d'une r You may specify marking a message with one or more IMAP flags as one of the actions in a rule. The possible values are Seen, Flagged For Followup, Answered, and Deleted. + --> - + Règle de filtrage: Correspondances Il y a 3 composantes pour chaque condition dans une règle. La première est le champ à examiner. La seconde est le type de comparaison à exécuter. Le troisième est la valeur à laquelle le champ devrait être comparé. Il y a quelques types de comparaisons qui peuvent être effectuées. Les comparaisons disponibles pour n'importe quel champ dépendront du type du champ et de ce que le logiciel de filtrage peut manipuler. @@ -266,7 +272,85 @@ Sera consid - + Règle de filtrage: Nom diff --git a/ingo/locale/lv_LV/help.xml b/ingo/locale/lv_LV/help.xml index f3dfa4a8f..6db87f010 100644 --- a/ingo/locale/lv_LV/help.xml +++ b/ingo/locale/lv_LV/help.xml @@ -26,6 +26,11 @@ Blacklist The blacklist is a list of email addresses known to send email that you do not wish to see in your INBOX. + --> Melnais saraksts: Darbîba @@ -64,6 +69,14 @@ "delete" is selected, the messages will be discarded before ever being stored in your Inbox. If "move to folder" is selected, they will be delivered to the selected folder. + --> Melnais saraksts: Adreses @@ -90,6 +103,11 @@ Blacklist: Addresses The list of addresses to block. Each address should be entered on a separate line. + --> Likumi: Filtru likumi @@ -152,6 +170,20 @@ here. For example, if an email is deleted by the blacklist, the following rules will not have any influence on this email. + --> Pârsûtît @@ -179,6 +211,11 @@ Forward You may choose to automatically forward your incoming mail to a number of other mail addresses. + --> Pârsûtît: Adreses @@ -210,6 +247,12 @@ You may choose to have your incoming mail redirected to another account. You may enter as many addresses as you like. Enter each address on a new line. + --> Pârsûtît: Saglabât kopiju @@ -241,6 +284,12 @@ If you select this option, a copy of your incoming messages will be saved in this account as well as being sent to the addresses to which you have your mail forwarded. + --> Izvçle: Râdît detalizçtus filtru statusa paziòojumus? @@ -279,6 +328,14 @@ will result in a separate notification message output to the screen immediately after the message is processed. If set to no, only a summary of filter actions will be output to the screen. + --> Izvçle: Filtrçt tikai [ne]lasîtâs vçstules? @@ -313,6 +370,13 @@ attempt to apply rules to the INBOX. You can either apply filters to all messages, apply filters ONLY to messages that are marked unseen, or apply filters ONLY to message that have been marked seen. + --> Filtra likumi @@ -360,6 +424,16 @@ be performed on that message. Filters can be very useful for automatically deleting unwanted mail, or making your mail account more managable by storing related messages into different folders. + --> Filtra likums: Darbîba @@ -486,6 +560,30 @@ Reject this message with reason The original message will be discarded, and a new message will be sent to the sender with the text that you specify. + --> Filtra likums: Kombinçt opcijas @@ -548,6 +646,18 @@ Or If you select OR, the specified actions will be executed if at least one of the conditions is met. + --> Filtra likums: Atzîmçt vçstuli @@ -578,6 +688,12 @@ You may specify marking a message with one or more IMAP flags as one of the actions in a rule. The possible values are Seen, Flagged For Followup, Answered, and Deleted. + --> Filtra likums: Atbilstîbas @@ -952,6 +1068,84 @@ Greater than This is a relational test which will compare the value you specify and the value in the message header numerically. + --> Filtra likums: Nosaukums @@ -978,6 +1172,11 @@ Filter Rule: Name This is a descriptive name for a rule. You may use it to identify a rule in your filter listing. + --> Filtra likums: Beigt pârbaudi @@ -1004,6 +1203,11 @@ Filter Rule: Stop Checking If this option is checked, and a message matches this rule, the remaining filters will not be processed. + --> Brîvdienas @@ -1035,6 +1239,12 @@ Vacation messages are automatic responses sent to people when they email you. They are normally used when you are away for a long period of time. + --> Vacation Period @@ -1069,6 +1279,12 @@ Checking this option will cause vacation responses to not be sent to messages that appear to come from mailing lists or that are marked as bulk mail. + --> Brîvdienas: Atbildes intervâls @@ -1095,6 +1311,11 @@ Vacation: Reply Interval This is the number of days to wait before sending an autoresponse to an address that has already received one. + --> Brîvdienas: Manas adreses @@ -1121,6 +1342,11 @@ Vacation: My Email Addresses If you have more than one email address coming to this mailbox then specify them here. + --> Brîvdienas: Nesûtît @@ -1147,6 +1373,11 @@ Vacation: No Responses Don't send the vacation message to these recipients. Each address should be on its own line. + --> Brîvdienas: Iemesls @@ -1169,6 +1400,10 @@ Vacation: Vacation Reason This is the text that will be sent in your vacation responses. + --> Brîvdienas: Temats @@ -1191,6 +1426,10 @@ Vacation: Vacation Subject This is the subject that will be used for vacation responses. + --> Baltais saraksts @@ -1222,6 +1461,12 @@ The whitelist is a list of (legitimate) email addresses that you always wish to see in your INBOX. Each address should be entered on a separate line. + --> Baltais saraksts: Adreses @@ -1244,6 +1489,10 @@ Whitelist: Addresses TODO. Each address should be entered on a separate line. + --> Spam Filtering: Spam Level -- 2.11.0