Re: [exim] Testing for the absence of a header

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Philip Hazel
Fecha:  
A: Marc Sherman
Cc: exim-users
Asunto: Re: [exim] Testing for the absence of a header
On Sat, 21 Oct 2006, Marc Sherman wrote:

> >   if "${if def:header_x-spam-score{yes}{no}}" is "no" then
> >     save ".spam/"
> >   endif

>
> You're missing the terminating colon on "header_x-spam-score:". The colon can
> only be omitted if the following character is whitespace.
>
> Philip, that optional colon-preceding-whitespace has been a frequently
> recurring issue. Requiring the colon at all times would certainly be the kind
> of incompatible change you usually resist, but I think it would be a
> worthwhile one, because it would let you emit better error messages when it's
> not there, instead of silently extending the name of the header beyond what
> the user may have intended.


I entirely agree that it was a mistake not to require the colon.
However, the filter above should give *an* error. When I use -be to test
that expansion, I get

Failed: missing or misplaced { or }

The OP didn't quote that - he just said "it doesn't work". I get a
feeling (maybe wrong) that he didn't look for the error message at all.
And not enough people know about testing filters using the -bf option,
even if just to check that the syntax is OK. That would have given a
clue here.

It is true that if I required the colon, I could make the message
something like

  Failed: missing or misplaced { or } (did you forget a colon after a 
    header name?)


Actually, I could probably do that anyway, without a mandatory colon.
Exim just has to remember that it was looking for a header name
somewhere in the expansion. I'll do it.

But of course it won't help those who don't look at the error message...


-- 
Philip Hazel            University of Cambridge Computing Service
Get the Exim 4 book:    http://www.uit.co.uk/exim-book