FIX: dav_submission: filter non ascii-chars in directory and file names.
This commit is contained in:
@@ -153,10 +153,17 @@ class UploadView(generic.edit.FormView):
|
|||||||
def _sanitize_filename(self, input):
|
def _sanitize_filename(self, input):
|
||||||
max_length = None
|
max_length = None
|
||||||
discard_chars = u''
|
discard_chars = u''
|
||||||
|
replace_chars = {
|
||||||
|
u'ä': u'ae',
|
||||||
|
u'ö': u'oe',
|
||||||
|
u'ü': u'ue',
|
||||||
|
u'ß': u'ss',
|
||||||
|
u'Ä': u'Ae',
|
||||||
|
u'Ö': u'Oe',
|
||||||
|
u'Ü': u'Ue',
|
||||||
|
}
|
||||||
allowed_chars = (u'abcdefghijklmnopqrstuvwxyz'
|
allowed_chars = (u'abcdefghijklmnopqrstuvwxyz'
|
||||||
u'äöüß'
|
|
||||||
u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
u'ÄÖÜ'
|
|
||||||
u'0123456789'
|
u'0123456789'
|
||||||
u'._-')
|
u'._-')
|
||||||
non_allowed_substitute = u'_'
|
non_allowed_substitute = u'_'
|
||||||
@@ -169,6 +176,8 @@ class UploadView(generic.edit.FormView):
|
|||||||
for c in input:
|
for c in input:
|
||||||
if c in discard_chars:
|
if c in discard_chars:
|
||||||
continue
|
continue
|
||||||
|
elif c in replace_chars:
|
||||||
|
r += replace_chars[c]
|
||||||
elif allowed_chars is not None and c in allowed_chars:
|
elif allowed_chars is not None and c in allowed_chars:
|
||||||
r += c
|
r += c
|
||||||
elif allowed_chars is None and c.isalnum():
|
elif allowed_chars is None and c.isalnum():
|
||||||
|
|||||||
Reference in New Issue
Block a user