Make sure to operate on unicode when sanitzing sd filenames

Should fix #834
This commit is contained in:
Gina Häußge 2015-04-13 10:22:43 +02:00
parent a34cbc58dc
commit 594636e0e3
2 changed files with 6 additions and 1 deletions

View file

@ -306,6 +306,11 @@ def find_collision_free_name(filename, extension, existing_filenames, max_power=
# TODO unit test!
if not isinstance(filename, unicode):
filename = unicode(filename)
if not isinstance(extension, unicode):
extension = unicode(extension)
def make_valid(text):
return re.sub(r"\s+", "_", text.translate({ord(i):None for i in ".\"/\\[]:;=,"})).lower()

View file

@ -313,7 +313,7 @@ class VirtualPrinter():
def _selectSdFile(self, filename):
if filename.startswith("/"):
filename = filename[1:]
file = os.path.join(self._virtualSd, filename).lower()
file = os.path.join(self._virtualSd, filename.lower())
if not os.path.exists(file) or not os.path.isfile(file):
self.outgoing.put("open failed, File: %s." % filename)
else: