diff --git a/setup.py b/setup.py index b33576f540..c4b030c73f 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ setup( "Pillow>=2.3.0", "beautifulsoup4>=4.3.2", "lxml>=3.3.0", + 'Unidecode>=0.04.14', "BeautifulSoup==3.2.1", # django-compressor gets confused if we have lxml but not BS3 installed ], zip_safe=False, diff --git a/wagtail/wagtailimages/models.py b/wagtail/wagtailimages/models.py index d30f969ad5..61082c2cbc 100644 --- a/wagtail/wagtailimages/models.py +++ b/wagtail/wagtailimages/models.py @@ -14,6 +14,8 @@ from django.utils.html import escape from django.conf import settings from django.utils.translation import ugettext_lazy as _ +from unidecode import unidecode + from wagtail.wagtailadmin.taggable import TagSearchable from wagtail.wagtailimages import image_ops @@ -25,8 +27,9 @@ class AbstractImage(models.Model, TagSearchable): folder_name = 'original_images' filename = self.file.field.storage.get_valid_name(filename) + # do a unidecode in the filename and then # replace non-ascii characters in filename with _ , to sidestep issues with filesystem encoding - filename = "".join((i if ord(i) < 128 else '_') for i in filename) + filename = "".join((i if ord(i) < 128 else '_') for i in unidecode(filename)) while len(os.path.join(folder_name, filename)) >= 95: prefix, dot, extension = filename.rpartition('.')