HTML Input: Collapse multiple spaces in filenames when sanitizing them. Fixes #1788187 [When creating epub references with spaces in content.opf should be transformed in %20](https://bugs.launchpad.net/calibre/+bug/1788187)

This commit is contained in:
Kovid Goyal 2018-08-21 22:43:30 +05:30
parent 7f255f141d
commit 085e813cbc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -20,7 +20,9 @@ from calibre.utils.imghdr import what
def sanitize_file_name(x): def sanitize_file_name(x):
return re.sub(r'[?&=;#]', '_', ascii_filename(x)) ans = re.sub(r'\s+', ' ', re.sub(r'[?&=;#]', '_', ascii_filename(x))).strip().rstrip('.')
ans, ext = ans.rpartition('.')[::2]
return ans.strip() + '.' + ext.strip()
class HTMLInput(InputFormatPlugin): class HTMLInput(InputFormatPlugin):