Changeset 348
- Timestamp:
- 04/12/10 18:04:24 (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r347 r348 1 1 2010-XX-XX 2 * Re-enabled some code that normalized the filenames for attachment 2 3 3 4 -
trunk/email2trac.py.in
r347 r348 505 505 n = n + 1 506 506 print 'TD: part%d: Content-Type: %s' % (n, part.get_content_type()) 507 print 'TD: part%d: filename: %s' % (n, part.get_filename()) 508 509 part_file = os.path.join(self.TMPDIR, part.get_filename()) 507 print 'TD: part%d: filename: %s' % (n, filename) 508 509 ## Forbidden chars 510 # 511 filename = filename.replace('\\', '_') 512 filename = filename.replace('/', '_') 513 514 515 part_file = os.path.join(self.TMPDIR, filename) 510 516 print 'TD: writing part%d (%s)' % (n,part_file) 511 517 … … 800 806 body_text = self.body_text(message_parts) 801 807 808 if self.VERSION == 0.9: 809 error_with_attachments = self.attach_attachments(message_parts, True) 810 else: 811 error_with_attachments = self.attach_attachments(message_parts) 812 802 813 if body_text.strip() or update_fields or self.properties: 803 814 if self.DRY_RUN: 804 815 print 'DRY_RUN: tkt.save_changes(self.author, body_text, ticket_change_number) ', self.author, cnum 805 816 else: 817 if error_with_attachments: 818 body_text = '%s\\%s' %(error_with_attachments, body_text) 819 806 820 tkt.save_changes(self.author, body_text, when, None, str(cnum)) 807 821 808 822 809 if self.VERSION == 0.9:810 error_with_attachments = self.attach_attachments(message_parts, True)811 else:812 error_with_attachments = self.attach_attachments(message_parts)823 #if self.VERSION == 0.9: 824 # error_with_attachments = self.attach_attachments(message_parts, True) 825 #else: 826 # error_with_attachments = self.attach_attachments(message_parts) 813 827 814 828 if self.notification and not spam: … … 1047 1061 att.description = self.email_to_unicode('Added by email2trac') 1048 1062 1049 att.insert(filename, fd, file_size)1050 1051 #except util.TracError, detail:1052 # print detail1063 try: 1064 att.insert(filename, fd, file_size) 1065 except OSError, detail: 1066 status = '%s\nFilename %s could not be saved, problem: %s' %(status, filename, detail) 1053 1067 1054 1068 # Remove the created temporary filename … … 1486 1500 filename = '%s%s' % (filename, ext) 1487 1501 1488 ## Discard relative paths in attachment names 1489 # 1490 filename = filename.replace('\\', '/').replace(':', '/') 1491 filename = os.path.basename(filename) 1502 ## Discard relative paths for windows/unix in attachment names 1503 # 1504 #filename = filename.replace('\\', '/').replace(':', '/') 1505 filename = filename.replace('\\', '_') 1506 filename = filename.replace('/', '_') 1492 1507 1493 1508 # … … 1496 1511 # Check python version and then try it 1497 1512 # 1498 if sys.version_info[0] > 2 or (sys.version_info[0] == 2 and sys.version_info[1] >= 3):1499 try:1500 filename = unicodedata.normalize('NFC', unicode(filename, 'utf-8')).encode('utf-8')1501 except TypeError:1502 pass1513 #if sys.version_info[0] > 2 or (sys.version_info[0] == 2 and sys.version_info[1] >= 3): 1514 # try: 1515 # filename = unicodedata.normalize('NFC', unicode(filename, 'utf-8')).encode('utf-8') 1516 # except TypeError: 1517 # pass 1503 1518 1504 1519 # Make the filename unique for this ticket
Note: See TracChangeset
for help on using the changeset viewer.