mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-13 02:10:49 +01:00
Fix issue #72 - international characters in e-mail attachment filenames
threw up errors. Also sanitised filenames to remove anything other than 'a-zA-Z0-9._-'. Thanks to mdornseif for the patch.
This commit is contained in:
parent
70c9d2d523
commit
576150c40d
@ -292,17 +292,18 @@ def ticket_from_message(message, queue):
|
||||
print (" [%s-%s] %s%s" % (t.queue.slug, t.id, t.title, update)).encode('ascii', 'replace')
|
||||
|
||||
for file in files:
|
||||
filename = file['filename'].replace(' ', '_')
|
||||
if file['content']:
|
||||
filename = file['filename'].encode('ascii', 'replace').replace(' ', '_')
|
||||
filename = re.sub('[^a-zA-Z0-9._-]+', '', filename)
|
||||
a = Attachment(
|
||||
followup=f,
|
||||
filename=filename,
|
||||
mime_type=file['type'],
|
||||
size=len(file['content']),
|
||||
)
|
||||
a.file.save(file['filename'], ContentFile(file['content']), save=False)
|
||||
a.file.save(filename, ContentFile(file['content']), save=False)
|
||||
a.save()
|
||||
print (" - %s" % file['filename']).encode('ascii', 'replace').encode('ascii', 'replace')
|
||||
print " - %s" % filename
|
||||
|
||||
return t
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user