[Mimedefang] RE: Subject query (Rob Dege)
David F. Skoll
dfs at roaringpenguin.com
Wed Apr 3 17:51:02 EST 2002
On Wed, 3 Apr 2002 no-reply at aftermagic.com wrote:
> Here's the function, perhaps something similar to this can makes its
> way into future revisions of MimeDefang?!?
I'm reluctant to include functions like this on both technical and
philosophical grounds. I will include it in a contrib/ directory,
though.
The philosophical grounds: I think scanning content for specific "dirty"
words goes beyond the intent of MIMEDefang, which is to stop dangerous
content, and detect Spam. But that's just my opinion; what you use it for
is up to you.
The technical grounds: The function has many problems; let me suggest
some improvements.
The dirty-word list is loaded for each message. You might as well do it
once when the filter is loaded. You could write a function called
init_dirty_list, and call it directly from /etc/mail/mimedefang-filter:
# Outside of filter_begin, filter_end, etc...
init_dirty_list();
> if($mode eq "body") {
> unless (open(MESG, "<INPUTMSG")) { # get the message to scan
INPUTMSG contains the raw message, including possibly encoded parts. The
match will fail on Base64-encoded parts. Instead, you want to scan each
part in filter(). You can get at the decoded content by opening
$entity->bodyhandle->path (if it is defined.)
You really want three functions:
dirty_subject() which uses the $Subject global variable
dirty_headers() which opens "./HEADERS", and
dirty_entity($entity) which opens $entity->bodyhandle->path
Finally, a more ambitious improvement might be to compile all the
dirty phrases into one moster Perl regexp, and let Perl optimize the
matching instead of rolling your own loop. :-)
(Btw, to the original poster: Please use your real e-mail address when
posting to the list. This list is a closed list -- you have to subscribe
to post. I was kind and let the message through, but don't like doing
that.)
--
David.
More information about the MIMEDefang
mailing list