Raise exception if attempted override name is invalid.

Technically it doesn't really matter because the override is not
used for any file ops, but I don't like the idea of busted
path-looking strings being displayed anywhere on the interface.
This commit is contained in:
voussoir 2018-02-17 15:47:26 -08:00
parent 606a66cbf9
commit 5d6c5ef2b4

View file

@ -1036,10 +1036,12 @@ class Photo(ObjectBase):
self.__reinit__() self.__reinit__()
def set_override_filename(self, new_filename, *, commit=True): def set_override_filename(self, new_filename, *, commit=True):
if not new_filename: if new_filename is not None:
new_filename = None cleaned = helpers.remove_path_badchars(new_filename)
else: cleaned = cleaned.strip()
new_filename = helpers.remove_path_badchars(new_filename) if not cleaned:
raise ValueError('"%s" is not valid.' % new_filename)
new_filename = cleaned
data = { data = {
'id': self.id, 'id': self.id,
@ -1051,6 +1053,8 @@ class Photo(ObjectBase):
self.photodb.log.debug('Committing - set override filename') self.photodb.log.debug('Committing - set override filename')
self.photodb.commit() self.photodb.commit()
self.__reinit__()
def sorted_tags(self): def sorted_tags(self):
tags = self.get_tags() tags = self.get_tags()
tags.sort(key=lambda x: x.qualified_name()) tags.sort(key=lambda x: x.qualified_name())