Sanitized filenames
This commit is contained in:
parent
22759f5bec
commit
f35cbbda3f
@ -421,6 +421,9 @@ class Room(object):
|
|||||||
def __str__(self, *args, **kwargs):
|
def __str__(self, *args, **kwargs):
|
||||||
return self.getName()
|
return self.getName()
|
||||||
|
|
||||||
|
def sanitizeFilename(self, filename, blacklist="<>:/\\|?*\"", placeholder="_"):
|
||||||
|
return ''.join([c if c not in blacklist and ord(c) >= 32 else placeholder for c in filename])
|
||||||
|
|
||||||
def writeToFile(self):
|
def writeToFile(self):
|
||||||
if self._roomsDir is None:
|
if self._roomsDir is None:
|
||||||
return
|
return
|
||||||
@ -431,7 +434,7 @@ class Room(object):
|
|||||||
data['playlist'] = self._playlist
|
data['playlist'] = self._playlist
|
||||||
data['playlistIndex'] = self._playlistIndex
|
data['playlistIndex'] = self._playlistIndex
|
||||||
data['position'] = self._position
|
data['position'] = self._position
|
||||||
with open(os.path.join(self._roomsDir, self._name+'.room'), "w") as outfile:
|
with open(os.path.join(self._roomsDir, self.sanitizeFilename(self._name)+'.room'), "w") as outfile:
|
||||||
json.dump(data, outfile)
|
json.dump(data, outfile)
|
||||||
|
|
||||||
def loadFromFile(self, filename):
|
def loadFromFile(self, filename):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user