Re: add to senders real name

Re: add to senders real name

am 02.04.2008 10:47:24 von ska

Grant Taylor wrote:
> Use MIMEdefang to edit the From: header with in the message.
>
> I'd think a simple RegEx would do the trick "/\(From:.*\)\(<.*>.*\)/\1
> [Safe] \2/" (or the likes) should do what you are needing. (Note: I've
> never used MIMEdefang and I'm not all that familiar with Perl RegExs,
> but that will work in vim and sed so I know that it is close to what you
> need in Perl.)

If you still have problems and are using the regex above:

/\(From:.*\)\(<.*>.*\)/\1 [Safe] \2/

this is no valid perl regex, use this one:

/(From:.*)(<.*>.*)/$1 [Safe] $2/

However, in MIMEDefang you would probably need to do something like
this:

open(HEADER, 'HEADER');
while(

) {
if(/^From:\s*(.*)\s*(<[^<]*>)/) {
my $cmt = $1;
my $addr = $2;
$cmt =~ s/^"//s; # deqote comment
$cmt =~ s/"$//s;
action_delete_all_headers('from');
action_add_header('from', "\"$cmt [SAFE]\" $addr");
last;
}
}


close HEADER;

Re: add to senders real name

am 02.04.2008 16:15:39 von gtaylor

On 04/02/08 03:47, ska wrote:
> If you still have problems and are using the regex above:
>
> /\(From:.*\)\(<.*>.*\)/\1 [Safe] \2/
>
> this is no valid perl regex, use this one:
>
> /(From:.*)(<.*>.*)/$1 [Safe] $2/

Thank you for the correction.

Despite Regular Expressions being mostly regular, the nuances of each
implementation is different. Perl's version will utterly bomb out in
Vim, while Vim's version will utterly bomb out in Perl. Despite the
method being the same, the syntax is different. :(



Grant. . . .