import email txt = """Subject: IE is Evil Content-Type: image/pjpeg; name="Jim&&Jill" """ msg = email.message_from_string(txt) #print msg.get('content-type') print msg.get_params() # test a workaround: from email.Message import Message from email.Parser import Parser from email import Utils # helper to split params while ignoring ';' inside quotes def _parseparam(str): plist = [] while str[:1] == ';': str = str[1:] end = str.find(';') while end > 0 and (str.count('"',0,end) & 1): end = str.find(';',end + 1) if end < 0: end = len(str) f = str[:end] if '=' in f: i = f.index('=') f = f[:i].strip().lower() + \ '=' + f[i+1:].strip() plist.append(f.strip()) str = str[end:] return plist class MimeMessage(Message): def _get_params_preserve(self,failobj=None,header='content-type'): "Return all parameter names and values. Use parser that handles quotes." missing = [] value = self.get(header, missing) if value is missing: return failobj params = [] for p in _parseparam(';' + value): try: name, val = p.split('=', 1) name = name.strip() val = val.strip() except ValueError: # Must have been a bare attribute name = p.strip() val = '' params.append((name, val)) params = Utils.decode_params(params) return params parser = Parser(MimeMessage) msg = parser.parsestr(txt) print msg.get_params()