diff --git a/oml/item/models.py b/oml/item/models.py index 5b2e6f8..77e6374 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -530,6 +530,7 @@ class File(db.Model): filename = '%s.%s' % (title, extension) new_path = os.path.join(author[0].upper(), author, filename) + new_path = new_path.replace('\x00', '') if self.path == new_path: return h = '' diff --git a/oml/media/__init__.py b/oml/media/__init__.py index 32e34ba..3270bf6 100644 --- a/oml/media/__init__.py +++ b/oml/media/__init__.py @@ -54,6 +54,11 @@ def metadata(f, from_=None): data[key] = info[key] if key in opf_info: data[key] = opf_info[key] + if key in data[key]: + if isinstance(data[key], basestring): + data[key] = data[key].replace('\x00', '') + elif isinstance(data[key], list): + data[key] = [e.replace('\x00', '') if isinstance(e, basestring) else e for e in data[key]] if 'isbn' in data: data['primaryid'] = ['isbn', data['isbn'][0]] elif 'asin' in data: