Re: [exim] Advanced regexp question

Top Page
Delete this message
Reply to this message
Author: Magnus Holmgren
Date:  
To: exim-users
Subject: Re: [exim] Advanced regexp question
On Wednesday 30 May 2007 15:53, jori.hamalainen@??? wrote:
> I need to build RFC2047 encoded text length evaluator via PCRE. I know that
> newest Exim (4.66) has ${rfc2047d:[string]} expansion. But upgrading Exim
> is too much of a hassle for just that purpose.


If you need this expansion item but don't want to perform a full upgrade, you
could try and build your current version with only that patch applied. It's
probably easier than messing with regexes.

http://www.exim.org/viewvc/exim/exim-src/src/expand.c?r1=1.78&r2=1.79&view=patch

*But*, I'm not sure what exactly you want. If you simply need the decoded
length, $header_*: will do the decoding for you, so $header_Subject: below
should already have the encoding removed.

> RFC2047 syntax for quoted-printable: =?utf-8?Q?foobar=7C=7C?=
>
> I need a length of this string decoded: like ${strlen:foobar||}
>
> Partial result can be done with nested ${sg}, but that is not correctly
> working..
> ${strlen:${sg{${sg{$header_Subject:}{\N\=\?.*?\?[Qq]\?(\S*?)\?\=\N}{\$1}}}{
>\N\=[a-fA-F0-9]{2}\N}{#}}}
>
> - for subject line "=?utf-8?Q?foobar=7C=7C?=" it gives the correct length
> - because it matches also actual subject "foobar=7C=7C" to "foobar##" and
> returns a wrong length of string (4 chars too short).


Yes, to get the length of the decoded string you basically have to decode it.
There are far too many things to keep track of for a regexp to work.

-- 
Magnus Holmgren        holmgren@???
                       (No Cc of list mail needed, thanks)


"Exim is better at being younger, whereas sendmail is better for
Scrabble (50 point bonus for clearing your rack)" -- Dave Evans