Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #108 from JiriKr/master
Browse files Browse the repository at this point in the history
Fixed filename split on windows
  • Loading branch information
dstegelman authored Nov 30, 2017
2 parents 0fcb8d6 + 6dcde67 commit 72cd782
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mailqueue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def add_attachment(self, attachment):
if self.pk is None:
self._save_without_sending()

original_filename = attachment.file.name.split('/')[-1]
original_filename = attachment.file.name.split(os.sep)[-1]
file_content = ContentFile(attachment.read())

new_attachment = Attachment()
Expand Down
3 changes: 2 additions & 1 deletion mailqueue/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.utils.crypto import get_random_string
Expand Down Expand Up @@ -26,7 +27,7 @@ def get_storage():
def upload_to(instance, filename):
# Because filename may also contain path
# which is unneeded and may be harmful
filename = filename.split('/')[-1]
filename = filename.split(os.sep)[-1]
# Because instead of filesystem, email message
# can have multiple attachments with the same filename
return '{0}/{1}_{2}'.format(MAILQUEUE_ATTACHMENT_DIR, get_random_string(length=24), filename)

0 comments on commit 72cd782

Please sign in to comment.