[Mimedefang] Update to MIMEDefang Filter KAM

Kevin A. McGrail kmcgrail at pccc.com
Fri Apr 16 15:58:46 EDT 2004


Thanks to Joe Brennan, we have implemented a new addition to our MIMEDefang
filter to disable iframe/object/script elements from HTML emails.  It's in
the filter () section in the file here:

http://www.peregrinehw.com/downloads/MIMEDefang/mimedefang-filter-KAM

and here's the code though word wrapping will probably kill it:

    #Disable bad HTML code -- Based on work by Columbia University / Joseph
Brennan
    #Modified by KAM 2004-04-16
    if ($type eq "text/html") {
      my($currentline, $output, $badtag);

      $badtag = 0;
      $output = "";

      if ($io = $entity->open("r")) {
        while (defined($currentline = $io->getline)) {
          if ($currentline =~ s/<(iframe|script|object)\b/<no-$1 /ig) {
            $badtag++;
          }
          $output .= $currentline;
        }
        $io->close;

        if ($badtag) {
          if ($io = $entity->open("w")) {
            $io->print($output);
            $io->close;
          }
          md_graphdefang_log('modify',"$badtag Iframe/Object/Script tag(s)
deactivated by MIMEDefang using Columbia filter");
          action_change_header("X-Warning", "$badtag Iframe/Object/Script
tag(s) deactivated by MIMEDefang using Columbia filter");
          action_rebuild();
        }
      }
    }

regards,
KAM



More information about the MIMEDefang mailing list