Unverified Commit 969105b2 authored by Ryan Holmes's avatar Ryan Holmes Committed by GitHub

Trim whitespace from filename

This avoids an OSError when the book's metadata has whitespace at the end of it.
parent 1a1d105f
...@@ -254,7 +254,7 @@ def get_valid_filename(value, replace_whitespace=True): ...@@ -254,7 +254,7 @@ def get_valid_filename(value, replace_whitespace=True):
value = re.sub(r'[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U) value = re.sub(r'[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U)
# pipe has to be replaced with comma # pipe has to be replaced with comma
value = re.sub(r'[\|]+', u',', value, flags=re.U) value = re.sub(r'[\|]+', u',', value, flags=re.U)
value = value[:128] value = value[:128].strip()
if not value: if not value:
raise ValueError("Filename cannot be empty") raise ValueError("Filename cannot be empty")
if sys.version_info.major == 3: if sys.version_info.major == 3:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment