mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Be very careful about filename length.
This commit is contained in:
parent
f19471cd1a
commit
5bd99b8b91
2 changed files with 7 additions and 4 deletions
|
|
@ -178,10 +178,13 @@ class Mailbox(models.Model):
|
|||
filename = part.get_filename()
|
||||
# ignore SMIME extension
|
||||
filename_basename, filename_extension = os.path.splitext(filename)
|
||||
if len(filename) > 100:
|
||||
buffer_space = 40
|
||||
if len(filename) > 100 - buffer_space:
|
||||
# Ensure that there're at least a few chars available afterward
|
||||
# for duplication things like _1, _2 ... _99
|
||||
filename = filename_basename[0:100-len(filename_extension)-3]
|
||||
# for duplication things like _1, _2 ... _99 and the FileField's
|
||||
# upload_to path.
|
||||
filename_basename = filename_basename[0:100-len(filename_extension)-buffer_space]
|
||||
filename = filename_basename + filename_extension
|
||||
if filename_extension in SKIPPED_EXTENSIONS:
|
||||
continue
|
||||
data = part.get_payload(decode=True)
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -4,7 +4,7 @@ tests_require=['django']
|
|||
|
||||
setup(
|
||||
name='django-mailbox',
|
||||
version='1.8',
|
||||
version='1.8.1',
|
||||
url='http://bitbucket.org/latestrevision/django-mailbox/',
|
||||
description='Import mail from POP3, IMAP, local mailboxes or directly from Postfix or Exim4 into your Django application automatically.',
|
||||
author='Adam Coddington',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue