pymilter  1.0.5
Classes | Functions | Variables
mime Namespace Reference

This module provides a "defang" function to replace naughty attachments. More...

Classes

class  MimeGenerator
 Fix multipart handling in email.Generator. More...
 
class  MimeMessage
 Enhance email.message.Message. More...
 
class  _defang
 
class  SGMLFilter
 
class  HTMLScriptFilter
 

Functions

def zipnames (txt)
 Return a list of filenames in a zip file. More...
 
def unquote (s)
 
def _unquotevalue (value)
 
def message_from_file (fp)
 
def check_ext (name)
 
def check_name (msg, savname=None, ckname=check_ext, scan_zip=False)
 
def check_attachments (msg, check, lev=None)
 
def check_html (msg, savname=None)
 
def _list_attach (msg)
 

Variables

 BytesIO = StringIO
 
 as_bytes
 
string extlist = ''.join(.split())
 
list bad_extensions = ['.' + x for x in extlist.split(',')]
 
string virus_msg
 
 defang = _defang()
 
 declname = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*')
 
 declstringlit = re.compile(r'(\'[^\']*\'|"[^"]*")\s*')
 
def msg = message_from_file(fp)
 

Detailed Description

This module provides a "defang" function to replace naughty attachments.

We also provide workarounds for bugs in the email module that comes with python. The "bugs" fixed mostly come up only with malformed messages - but that is what you have when dealing with spam.

Function Documentation

◆ check_attachments()

def mime.check_attachments (   msg,
  check,
  lev = None 
)
Scan attachments.
msg     MimeMessage
check   function(MimeMessage): int
        Return CONTINUE, REJECT, ACCEPT

Referenced by mime._defang.__call__().

◆ unquote()

def mime.unquote (   s)
Remove quotes from a string.

◆ zipnames()

def mime.zipnames (   txt)

Return a list of filenames in a zip file.

Embedded zip files are recursively expanded.

Referenced by mime.MimeMessage.getnames().

Variable Documentation

◆ virus_msg

string mime.virus_msg
Initial value:
1 = """This message appeared to contain a virus.
2 It was originally named '%s', and has been removed.
3 A copy of your original message was saved as '%s:%s'.
4 See your administrator.
5 """