[Mimedefang] Convert "special" characters within attachment filenames

David F. Skoll dfs at roaringpenguin.com
Thu Aug 8 18:25:01 EDT 2002


On Thu, 8 Aug 2002, Paul Jahnz wrote:

> I'm looking for a way to simply convert certain characters ( / \ : * ? " < >
> |  ) within filenames of attachments and replace them with a hyphen or some
> other character.

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();
}

> Unfortunately there are a few mac users that send
> attachments with these characters and my web based email app has problems
> opening and saving them.

Hmmm.... sounds like the Web-based email app is broken, possibly with
security flaws...

--
David.




More information about the MIMEDefang mailing list