filtering file types vs. extensions
Spicer, Kevin
Kevin.Spicer at BMRB.CO.UK
Fri Jun 6 18:29:20 IST 2003
> Does anyone know of a Perl module that uses the magic file? I
> would very
> much like to avoid having to write this, but I don't want to
> have to crank
> up the file command for every message batch if I can avoid it.
maybe you missed Mariano's post with the link in (it ended up in a different thread in my mailreader) so heres the link he found..
http://search.cpan.org/author/KNOK/File-MMagic-1.19/
Looks like this returns a mime type, which is probably the right way to go about this (saves processing the output from file too)
Given mime types I think probaly the easiest way would be to have a mimetypes.rules.conf which matches using RE's in the same way filename.rules.conf does.
I guess you run into issues if the output from filename rules and mimetype rules conflict (reject takes precedence?)
I don't think combining filename rules and mime types into one file would be very easy as it would be difficult to deal with wildcard matching, double extensions etc.
One suggestion which although complicating the implementation would make it much easier to construct rulesets based on file type is to have both a filename rules and mimetype rules file which assign category names (rather than simple yes/no) then have a much simpler ruleset determining action based on category (again reject takes precedence). Category names need to be arbitary so that users can extend the range of categories.
I guess thats not easy - but it could be quite handy!
BMRB International
http://www.bmrb.co.uk
+44 (0)20 8566 5000
_________________________________________________________________
This message (and any attachment) is intended only for the
recipient and may contain confidential and/or privileged
material. If you have received this in error, please contact the
sender and delete this message immediately. Disclosure, copying
or other action taken in respect of this email or in
reliance on it is prohibited. BMRB International Limited
accepts no liability in relation to any personal emails, or
content of any email which does not directly relate to our
business.
More information about the MailScanner
mailing list