From 969105b205b6ca382c0e6a2d7e030769f3cc338a Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 9 Aug 2020 01:08:00 -0400 Subject: [PATCH] Trim whitespace from filename This avoids an OSError when the book's metadata has whitespace at the end of it. --- cps/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/helper.py b/cps/helper.py index 681719a9..3e9f47c3 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -254,7 +254,7 @@ def get_valid_filename(value, replace_whitespace=True): value = re.sub(r'[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U) # pipe has to be replaced with comma value = re.sub(r'[\|]+', u',', value, flags=re.U) - value = value[:128] + value = value[:128].strip() if not value: raise ValueError("Filename cannot be empty") if sys.version_info.major == 3: