[Mimedefang] pure whitelisting

Paul Murphy Paul.Murphy at argentadiscovery.com
Tue Aug 12 12:43:50 EDT 2008


Jeff,

You need to read up on Perl string matching and regular expressions before trying to include such checks in your filter - it can be a minefield...

The most common approach is to use the search syntax:

	if ( $from =~ /user at domain.com/ )

However, this can throw up a number of obscure issues, such as whether the "." and the "@" in the address are special characters in a Perl regular expression match, and also whether the search string could possibly be found as a substring of something else, e.g. if your $from was "another-user at domain.com.hk", this search would match on it, so it's not unusual to see this written instead as:

	if ( $from =~ /^user\@domain\.com$/i )

This forces an exact match using the start of line (^) and end of line ($) markers, and escapes any special meaning in the non-alpha characters, and also does the whole comparison in a case-insensitive way.

Good luck....

Paul.


>>> jef moskot <jef at math.miami.edu> 12/08/2008 17:06 >>>
On Tue, 12 Aug 2008, David F. Skoll wrote:
> You can do that in filter_sender as follows:

OK, I've been flailing away trying to do the simplest of string compares
and I'm clearly missing something, because all my ifs fail.

What's the best way to output both strings I'm trying to compare so I can
see what backslashes or other weirdness I'm missing?

Right now I'm trying a basic if $from = "user at domain.com" type thing and I
can't even get a string match on the domain.

Jeffrey Moskot
System Administrator
jef at math.miami.edu 
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com 
MIMEDefang mailing list MIMEDefang at lists.roaringpenguin.com 
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang 



------------
Scanned by MIMEDefang - m7CG8deU022929


_______________________________________________________________________
Argenta Discovery Ltd, 8-9 Spire Green Centre, Harlow, Essex, CM19 5TR
Registered in England No. 3671653
_______________________________________________________________________ 




More information about the MIMEDefang mailing list