------------------------------------------------------------ revno: 6573 committer: Mark Sapiro <[EMAIL PROTECTED]> branch nick: 3.0 timestamp: Tue 2007-11-06 18:03:28 -0800 message: - Scrubber.py Fixed an issue where an implicit text/plain part without any headers gets lost. Moved the cleansing of the filename extension to a place where it is guaranteed to be a string as opposed to an empty list. modified: Mailman/Handlers/Scrubber.py
=== modified file 'Mailman/Handlers/Scrubber.py' --- a/Mailman/Handlers/Scrubber.py 2007-10-31 21:38:51 +0000 +++ b/Mailman/Handlers/Scrubber.py 2007-11-07 02:03:28 +0000 @@ -46,7 +46,7 @@ # Path characters for common platforms pre = re.compile(r'[/\\:]') # All other characters to strip out of Content-Disposition: filenames -# (essentially anything that isn't an alphanum, dot, slash, or underscore. +# (essentially anything that isn't an alphanum, dot, dash, or underscore). sre = re.compile(r'[^-\w.]') # Regexp to strip out leading dots dre = re.compile(r'^\.*') @@ -265,7 +265,7 @@ # If the message isn't a multipart, then we'll strip it out as an # attachment that would have to be separately downloaded. Pipermail # will transform the url into a hyperlink. - elif part and not part.is_multipart(): + elif part._payload and not part.is_multipart(): payload = part.get_payload(decode=True) ctype = part.get_content_type() # XXX Under email 2.5, it is possible that payload will be None. @@ -313,7 +313,8 @@ charsets = [] for part in msg.walk(): # TK: bug-id 1099138 and multipart - if not part or part.is_multipart(): + # MAS test payload - if part may fail if there are no headers. + if not part._payload or part.is_multipart(): continue # All parts should be scrubbed to text/plain by now. partctype = part.get_content_type() @@ -410,8 +411,6 @@ ext = fnext or guess_extension(ctype, fnext) else: ext = guess_extension(ctype, fnext) - # Allow only alphanumerics, dash, underscore, and dot - ext = sre.sub('', ext) if not ext: # We don't know what it is, so assume it's just a shapeless # application/octet-stream, unless the Content-Type: is @@ -421,6 +420,8 @@ ext = '.txt' else: ext = '.bin' + # Allow only alphanumerics, dash, underscore, and dot + ext = sre.sub('', ext) path = None # We need a lock to calculate the next attachment number with Lock(os.path.join(fsdir, 'attachments.lock')): -- https://code.launchpad.net/~mailman-coders/mailman/3.0 You are receiving this branch notification because you are subscribed to it. To unsubscribe from this branch go to https://code.launchpad.net/~mailman-coders/mailman/3.0/+subscription/mailman-checkins. _______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org