Esempio n. 1
0
 def __setitem__(self, name, val): 
     "Forbids multi-line headers, to prevent header injection." 
     if '\n' in val or '\r' in val: 
         raise BadHeaderError, "Header values can't contain newlines (got %r for header %r)" % (val, name) 
     if name == "Subject": 
         val = Header(val, settings.DEFAULT_CHARSET) 
     MIMEMultipart.__setitem__(self, name, val) 
Esempio n. 2
0
 def __setitem__(self, name, val):
     "Forbids multi-line headers, to prevent header injection."
     if '\n' in val or '\r' in val:
         raise BadHeaderError, _("Header values can't contain "
                                 "newlines (got %r for header %r)") % (val, name)
     try:
         val = str(force_unicode(val))
     except UnicodeEncodeError:
         if name.lower() in ('to', 'from', 'cc'):
             result = []
             for item in val.split(', '):
                 nm, addr = parseaddr(item)
                 nm = str(Header(nm, DEFAULT_CHARSET))
                 result.append(formataddr((nm, str(addr))))
             val = ', '.join(result)
         else:
             val = Header(force_unicode(val), DEFAULT_CHARSET)
     MIMEMultipart.__setitem__(self, name, val)
Esempio n. 3
0
 def __setitem__(self, name, val):
     name, val = forbid_multi_line_headers(name, val)
     MIMEMultipart.__setitem__(self, name, val)
Esempio n. 4
0
 def __setitem__(self, name, val):
     name, val = forbid_multi_line_headers(name, val, self.encoding)
     MIMEMultipart.__setitem__(self, name, val)
Esempio n. 5
0
 def __setitem__(self, name, val):
     """Forbids multi-line headers, to prevent header injection"""
     if '\n' in val or '\r' in val:
         raise BadHeaderError, \
             "Header values can't contain newlines (got %r for header %r)" % (val, name)
     MIMEMultipart.__setitem__(self, name, val)