Mailing List Archive

Exim filter get number before the dot
Heloo
In exim filter, numeric values in the "is above" rule are only accepted as integers
I have to execute the delivery command if the header value is above some number,
unfortunately many of them are written in the header and are decimal numbers, as a result I get an error
error in filter file: malformed numerical string "16.34"
here is my expression
if
$h_X-Spam-Potential: is not "" and ${sg{$h_X-Spam-Potential:}{^(\d+)\..*}{$1}} is above 16
then
......
theoretically, only the number 16 before the dot should be taken into account but unfortunately this doesn't happen :( thanks for help Slawek

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
On 09/09/2023 13:43, S?awomir Dworaczek via Exim-users wrote:
> In exim filter, numeric values in the "is above" rule are only accepted as integers
> I have to execute the delivery command if the header value is above some number,
> unfortunately many of them are written in the header and are decimal numbers, as a result I get an error
> error in filter file: malformed numerical string "16.34"
> here is my expression
> if
> $h_X-Spam-Potential: is not "" and ${sg{$h_X-Spam-Potential:}{^(\d+)\..*}{$1}} is above 16
> then
> ......
> theoretically, only the number 16 before the dot should be taken into account but unfortunately this doesn't happen :( thanks for help Slawek


Do the values have a fixed number of digits after the decimal point?
You could just delete the dot using ${sg...}.

Or if you know there's always at least one, and you only needs tenths,
ditto but only taking 1 digit for the second group.

--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
On Sat, Sep 09, 2023 at 02:43:52PM +0200, S?awomir Dworaczek via Exim-users wrote:
> here is my expression
> if
> $h_X-Spam-Potential: is not "" and ${sg{$h_X-Spam-Potential:}{^(\d+)\..*}{$1}} is above 16
> then
> ......
> theoretically, only the number 16 before the dot should be taken into account but unfortunately this doesn't happen :( thanks for help Slawek

Try:
${sg{$h_X-Spam-Potential:}{^(\\d+).*\$}{\$1}}
--
Eugene Berdnikov

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
unfortunately, it doesn't work, I get paniclog
Error in system filter: unrecognized condition word ""
Slawek


----- Original Message -----
From: "Evgeniy Berdnikov via Exim-users" <exim-users@lists.exim.org>
To: <exim-users@lists.exim.org>
Sent: Saturday, September 9, 2023 5:59 PM
Subject: [exim] Re: Exim filter get number before the dot


> On Sat, Sep 09, 2023 at 02:43:52PM +0200, S?awomir Dworaczek via
> Exim-users wrote:
>> here is my expression
>> if
>> $h_X-Spam-Potential: is not "" and
>> ${sg{$h_X-Spam-Potential:}{^(\d+)\..*}{$1}} is above 16
>> then
>> ......
>> theoretically, only the number 16 before the dot should be taken into
>> account but unfortunately this doesn't happen :( thanks for help Slawek
>
> Try:
> ${sg{$h_X-Spam-Potential:}{^(\\d+).*\$}{\$1}}
> --
> Eugene Berdnikov
>
> --
> ## subscription configuration (requires account):
> ##
> https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
> ## unsubscribe (doesn't require an account):
> ## exim-users-unsubscribe@lists.exim.org
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
Heloo Jeremy

This way the values always have one digit after the decimal point
I just need the number before the decimal point

Regards
Slawek


----- Original Message -----


From: "Jeremy Harris via Exim-users" <exim-users@lists.exim.org>
To: <exim-users@lists.exim.org>
Sent: Saturday, September 9, 2023 3:11 PM
Subject: [exim] Re: Exim filter get number before the dot


> On 09/09/2023 13:43, S?awomir Dworaczek via Exim-users wrote:
>> In exim filter, numeric values in the "is above" rule are only accepted
>> as integers
>> I have to execute the delivery command if the header value is above
>> some number,
>> unfortunately many of them are written in the header and are decimal
>> numbers, as a result I get an error
>> error in filter file: malformed numerical string "16.34"
>> here is my expression
>> if
>> $h_X-Spam-Potential: is not "" and
>> ${sg{$h_X-Spam-Potential:}{^(\d+)\..*}{$1}} is above 16
>> then
>> ......
>> theoretically, only the number 16 before the dot should be taken into
>> account but unfortunately this doesn't happen :( thanks for help Slawek
>
>
> Do the values have a fixed number of digits after the decimal point?
> You could just delete the dot using ${sg...}.
>
> Or if you know there's always at least one, and you only needs tenths,
> ditto but only taking 1 digit for the second group.
>
> --
> Cheers,
> Jeremy
>
>
> --
> ## subscription configuration (requires account):
> ##
> https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
> ## unsubscribe (doesn't require an account):
> ## exim-users-unsubscribe@lists.exim.org
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
On Sat, Sep 09, 2023 at 09:13:01PM +0200, S?awomir Dworaczek via Exim-users wrote:
> unfortunately, it doesn't work, I get paniclog
> Error in system filter: unrecognized condition word ""

Study debug output. Probably you made a typo.

> ----- Original Message ----- From: "Evgeniy Berdnikov via Exim-users"
> <exim-users@lists.exim.org>
> To: <exim-users@lists.exim.org>
> Sent: Saturday, September 9, 2023 5:59 PM
> Subject: [exim] Re: Exim filter get number before the dot
>
>
> > On Sat, Sep 09, 2023 at 02:43:52PM +0200, S?awomir Dworaczek via
> > Exim-users wrote:
> > > here is my expression
> > > if
> > > $h_X-Spam-Potential: is not "" and
> > > ${sg{$h_X-Spam-Potential:}{^(\d+)\..*}{$1}} is above 16
> > > then
> > > ......
> > > theoretically, only the number 16 before the dot should be taken
> > > into account but unfortunately this doesn't happen :( thanks for
> > > help Slawek
> >
> > Try:
> > ${sg{$h_X-Spam-Potential:}{^(\\d+).*\$}{\$1}}
> > --

--
Eugene Berdnikov

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
Unfortunately, any attempts to use regular expressions that attempt to
retrieve the number before the digit result in an error


$h_X-Spam-Potential:{{^(\\d+).*\$}{\$1}} is above 16

Error in system filter: unrecognized condition word ""

the workaround is to take the whole number and remove the dot
for example, if I want the condition to be met when the number is greater
than 16, I must enter the number 160 in the variable.

${sg{$h_X-Spam-Potential:}{\\.}{}} is above 160

I don't know if it's some kind of error in the system_filter code

Slawek

----- Original Message -----
From: "S?awomir Dworaczek" <slawek@dworaczek.info>
To: <exim-users@lists.exim.org>
Sent: Saturday, September 9, 2023 9:22 PM
Subject: Re: [exim] Re: Exim filter get number before the dot


> Heloo Jeremy
>
> This way the values always have one digit after the decimal point
> I just need the number before the decimal point
>
> Regards
> Slawek
>
>
> ----- Original Message -----
>
>
> From: "Jeremy Harris via Exim-users" <exim-users@lists.exim.org>
> To: <exim-users@lists.exim.org>
> Sent: Saturday, September 9, 2023 3:11 PM
> Subject: [exim] Re: Exim filter get number before the dot
>
>
>> On 09/09/2023 13:43, S?awomir Dworaczek via Exim-users wrote:
>>> In exim filter, numeric values in the "is above" rule are only accepted
>>> as integers
>>> I have to execute the delivery command if the header value is above
>>> some number,
>>> unfortunately many of them are written in the header and are decimal
>>> numbers, as a result I get an error
>>> error in filter file: malformed numerical string "16.34"
>>> here is my expression
>>> if
>>> $h_X-Spam-Potential: is not "" and
>>> ${sg{$h_X-Spam-Potential:}{^(\d+)\..*}{$1}} is above 16
>>> then
>>> ......
>>> theoretically, only the number 16 before the dot should be taken into
>>> account but unfortunately this doesn't happen :( thanks for help Slawek
>>
>>
>> Do the values have a fixed number of digits after the decimal point?
>> You could just delete the dot using ${sg...}.
>>
>> Or if you know there's always at least one, and you only needs tenths,
>> ditto but only taking 1 digit for the second group.
>>
>> --
>> Cheers,
>> Jeremy
>>
>>
>> --
>> ## subscription configuration (requires account):
>> ##
>> https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
>> ## unsubscribe (doesn't require an account):
>> ## exim-users-unsubscribe@lists.exim.org
>> ## Exim details at http://www.exim.org/
>> ## Please use the Wiki with this list - http://wiki.exim.org/
>>
>


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
On 09/09/2023 22:33, S?awomir Dworaczek via Exim-users wrote:
> Unfortunately, any attempts to use regular expressions that attempt to retrieve the number before the digit result in an error
>
>
> $h_X-Spam-Potential:{{^(\\d+).*\$}{\$1}} is above 16

That's written to be ambiguous, even with the questionable
dounbled backslash (compare with your original):
more-than-one digit (grabbed) followed by any number of anything,
then end-of-line.

I'd suggest going for at-least-one digit followed by an explicit dot.
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Exim filter get number before the dot [ In reply to ]
On Sat, Sep 09, 2023 at 10:43:54PM +0100, Jeremy Harris via Exim-users wrote:
> >
> > $h_X-Spam-Potential:{{^(\\d+).*\$}{\$1}}?is?above?16
>
> That's written to be ambiguous, even with the questionable
> dounbled backslash (compare with your original):

Doubling of backslash, as well as "\$" is necessary because ${sg..}
expands all of its arguments, and this behaviour is documented with
proper examples.

It's really ambiguous, because ".*" may contain digits, but default
PCRE behaviour is preference of leading pattern in expansion loop.
I do not remember how this "greediness" may be changed (one should
study docs), but this variant works:

# exim4 -be '${sg{16}{^(\\d+).*\$}{\$1}}'
16
exim4 -be '${sg{16.45}{^(\\d+).*\$}{\$1}}'
16
--
Eugene Berdnikov

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/