Ticket #247: 2longfilename.2.patch
File 2longfilename.2.patch, 3.8 KB (added by slevin@…, 13 years ago) |
---|
-
email2trac.
old new 75 75 import logging.handlers 76 76 import UserDict 77 77 import tempfile 78 import trans 78 79 79 80 from datetime import tzinfo, timedelta, datetime 80 81 from stat import * … … 229 230 230 231 self.system = None 231 232 233 ########## Rus2Eng converter filename ####################################################### 234 def FixFileName(self,filename): 235 filename = filename.replace(' ', '_') 236 return filename.encode('trans') 237 232 238 ########## Email Header Functions ########################################################### 233 239 234 240 def spam(self, message): … … 451 457 452 458 (original, filename, part) = item 453 459 460 # Convert rus UTF-8 to eng filename 461 filename = self.FixFileName(filename) 462 454 463 n = n + 1 455 464 print 'part%d: Content-Type: %s' % (n, part.get_content_type()) 456 465 457 466 s = 'part%d: filename: %s' %(n, filename) 458 467 self.print_unicode(s) 459 468 … … 863 872 # 864 873 if tkt['status'] in ['closed']: 865 874 workflow = self.parameters.workflow 875 # Fix situation with reopen ticket via e-mail 876 tkt['status'] = 'reopened' 877 tkt['resolution'] = '' 866 878 else: 867 879 workflow = None 868 880 … … 1171 1183 1172 1184 def attach_attachments(self, message_parts, update=False): 1173 1185 ''' 1174 save any attachments as files in the ticket 's directory1186 save any attachments as files in the ticket`s directory 1175 1187 ''' 1176 1188 self.logger.debug('function attach_attachments()') 1177 1189 … … 1194 1206 1195 1207 (original, filename, part) = item 1196 1208 1209 # Convert rus UTF-8 to eng filename 1210 filename = self.FixFileName(filename) 1211 1197 1212 ## We have to determine the size so we use this temporary solution. we must escape it 1198 1213 # else we get UnicodeErrors. 1199 1214 # … … 1830 1845 ## Check content type 1831 1846 # 1832 1847 if content_type in self.STRIP_CONTENT_TYPES: 1833 self.logger.debug("\t A %s attachment named '%s' was skipped" %(content_type, part.get_filename()))1848 self.logger.debug("\t A %s attachment named '%s' was skipped" %(content_type, self.FixFileName(part.get_filename()) )) 1834 1849 continue 1835 1850 1836 1851 ## Catch some mulitpart execptions … … 1863 1878 if not content_type in ['text/plain']: 1864 1879 1865 1880 if self.parameters.debug: 1866 s = '\t Filename: %s' % part.get_filename()1881 s = '\t Filename: %s' % self.FixFileName(part.get_filename()) 1867 1882 self.print_unicode(s) 1868 1883 1869 1884 ## First try to use email header function to convert filename. 1870 1885 # If this fails the use the plain filename 1871 1886 # 1872 1887 try: 1873 filename = self.email_to_unicode( part.get_filename())1888 filename = self.email_to_unicode(self.FixFileName(part.get_filename())) 1874 1889 except UnicodeEncodeError, detail: 1875 filename = part.get_filename()1890 filename = self.FixFileName(part.get_filename()) 1876 1891 1877 1892 message_parts.append((filename, part)) 1878 1893 … … 1960 1975 1961 1976 (filename, part) = item 1962 1977 1978 # Convert rus UTF-8 to eng filename 1979 filename = self.FixFileName(filename) 1980 1963 1981 ## If filename = None, use a default one 1964 1982 # 1965 1983 if filename in [ 'None']: … … 2060 2078 2061 2079 (original, filename, part) = part 2062 2080 inline = self.inline_part(part) 2081 # Convert rus UTF-8 to eng filename 2082 filename = self.FixFileName(filename) 2063 2083 2064 2084 ## Skip generation of attachment link if html is converted to text 2065 2085 #