[Mimedefang] Re: Convert "special" characters within attachment
Matt A. Gargett
MGargett at comshare.com
Sat Aug 10 13:37:01 EDT 2002
>> Would there be a way to convert multi-doted attachments such at
>> "this.is.my.attachment.doc" into "this-is-my-attachment.doc"?
Multi-dotted
>
>I'm sure there's a better way to write this, but this should work:>
>
>if ($fname && $fname =~ /\./) {
> my $one = substr($fname,0,rindex($fname,'.'));
> my $two = substr($fname,rindex($fname,'.'));
> $one =~ s/\./-/g;
> $fname = $one . $two;
> # ...and then the mime stuff and action_rebuild().
>}
This seems to work great for renaming my files, thanks very much.
However,
>From earlier David post:
>The following filter routine will do it. If you already have other tests
>in your filter routine, put this right at the beginning of the filter
>subroutine.
>
>sub filter {
> my($entity, $fname, $ext, $type) = @_;
>
> $fname =~ s@[/\\:*?"<>|]@- at g;
> $entity->head->mime_attr("Content-Type.name" => $name);
> $entity->head->mime_attr("Content-Disposition.filename" => $fname);
> $entity->head->mime_attr("Content-Description" => $fname);
> action_rebuild();
>}
When I put this after the file renaming above, all my HTML messages are
chomped and the HTML part is attached and the text of the HTML message is put
into a message. How can I not make it do that? Here is the snip from my
mimedefang-filter:
sub filter {
my($entity, $fname, $ext, $type) = @_;
if ($fname && $fname =~ /\./) {
my $one = substr($fname,0,rindex($fname,'.'));
my $two = substr($fname,rindex($fname,'.'));
$one =~ s/\./-/g;
$fname = $one . $two;
}
$fname =~ s@[/\\:*?"<>|]@- at g;
$entity->head->mime_attr("Content-Type.name" => $name);
$entity->head->mime_attr("Content-Disposition.filename" => $fname);
$entity->head->mime_attr("Content-Description" => $fname);
action_rebuild();
my($code, $category, $action) = entity_contains_virus_nai($entity);
# action_add_header('X-Virus-Scanned', $fname ? "$fname: $action" :
# "Message: $action");
$VirusScannerMessages =~ s/^\/var.*\n//g;
$VirusScannerMessages =~ s/^\s+//;
...
continue with vscan below...
Any suggestions on that one?
- Matt
More information about the MIMEDefang
mailing list