Changeset 377


Ignore:
Timestamp:
06/22/10 10:25:37 (14 years ago)
Author:
bas
Message:

Fixed some issues with Unicode suport for attachments, see #206

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r376 r377  
    521521                                print 'TD: part%d: filename: %s' % (n, filename)
    522522                        except UnicodeEncodeError, detail:
    523                                 print 'Filename can not be printed due to non-ascii characters'
     523                                print 'TD: part%d: filename: %s' % (n, util.text.unicode_quote(filename))
    524524
    525525                        ## Forbidden chars
     
    533533                                print 'TD: writing part%d (%s)' % (n,part_file)
    534534                        except UnicodeEncodeError, detail:
    535                                 print 'Filename can not be printed due to non-ascii characters'
     535                                print 'TD: writing part%d (%s)' % (n, util.text.unicode_quote(part_file))
    536536
    537537                        if self.DRY_RUN:
    538538                                print 'DRY_RUN: NOT saving attachments'
    539539                                continue
     540
     541                        part_file = util.text.unicode_quote(part_file)
    540542
    541543                        fx = open(part_file, 'wb')
     
    592594                if self.VERBOSE:
    593595                        print "VB: email_to_unicode"
     596
     597
    594598
    595599                results =  email.Header.decode_header(message_str)
     
    10961100                        (original, filename, part) = item
    10971101                        #
    1098                         # Must be tuneables HvB
    1099                         #
    1100                         path, fd =  util.create_unique_file(os.path.join(self.TMPDIR, filename))
     1102                        # We have to determine the size so we use this temporary solution. we must escape it
     1103                        # else we get UnicodeErrors.
     1104                        #
     1105                        path, fd =  util.create_unique_file(os.path.join(self.TMPDIR, util.text.unicode_quote(filename)))
    11011106                        text = part.get_payload(decode=1)
    11021107                        if not text:
     
    17681773                                                print 'TD:               Filename: %s' % part.get_filename()
    17691774                                        except UnicodeEncodeError, detail:
    1770                                                 print 'TD:               Filename: Can not be printed due to non-ascii characters'
    1771 
    1772                                 ## Convert 7-bit filename to 8 bits value
     1775                                                print 'TD:               Filename: %s' % util.text.unicode_quote(part.get_filename())
     1776
     1777                                ##
    17731778                                #
    1774                                 filename = self.email_to_unicode(part.get_filename())
     1779                                filename = part.get_filename()
    17751780                                message_parts.append((filename, part))
    17761781
Note: See TracChangeset for help on using the changeset viewer.