1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-10-19 01:27:40 +00:00

missing urllib migration

This commit is contained in:
林檎
2017-03-05 18:48:59 +08:00
parent c3fd205b7d
commit bf8688fee1
2 changed files with 13 additions and 9 deletions

View File

@@ -245,7 +245,10 @@ def get_valid_filename(value, replace_whitespace=True):
value=value.replace(u'ß',u'ss')
value = unicodedata.normalize('NFKD', value)
re_slugify = re.compile('[\W\s-]', re.UNICODE)
value = str(re_slugify.sub('', value).strip())
try:
value = str(re_slugify.sub('', value).strip())
except: #will exception on Python2.7
value = unicode(re_slugify.sub('', value).strip())
if replace_whitespace:
#*+:\"/<>? werden durch _ ersetzt
value = re.sub('[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U)