mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
HTML Input: Sanitize semi-colons from HTML filenames as they can cause problems with other EPUB consuming software. Fixes #1598719 [Name of linked file containing semicolon](https://bugs.launchpad.net/calibre/+bug/1598719)
This commit is contained in:
parent
1ff02ee830
commit
88e3e0fb9f
@ -18,6 +18,8 @@ from calibre.utils.localization import get_lang
|
|||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.utils.imghdr import what
|
from calibre.utils.imghdr import what
|
||||||
|
|
||||||
|
def sanitize_file_name(x):
|
||||||
|
return ascii_filename(x).replace(';', '_')
|
||||||
|
|
||||||
class HTMLInput(InputFormatPlugin):
|
class HTMLInput(InputFormatPlugin):
|
||||||
|
|
||||||
@ -145,8 +147,7 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
oeb.container = DirContainer(os.path.dirname(path), log,
|
oeb.container = DirContainer(os.path.dirname(path), log,
|
||||||
ignore_opf=True)
|
ignore_opf=True)
|
||||||
bname = os.path.basename(path)
|
bname = os.path.basename(path)
|
||||||
id, href = oeb.manifest.generate(id='html',
|
id, href = oeb.manifest.generate(id='html', href=sanitize_file_name(bname))
|
||||||
href=ascii_filename(bname))
|
|
||||||
htmlfile_map[path] = href
|
htmlfile_map[path] = href
|
||||||
item = oeb.manifest.add(id, href, 'text/html')
|
item = oeb.manifest.add(id, href, 'text/html')
|
||||||
if path == htmlpath and '%' in path:
|
if path == htmlpath and '%' in path:
|
||||||
@ -260,8 +261,7 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
link = link.lower()
|
link = link.lower()
|
||||||
if link not in self.added_resources:
|
if link not in self.added_resources:
|
||||||
bhref = os.path.basename(link)
|
bhref = os.path.basename(link)
|
||||||
id, href = self.oeb.manifest.generate(id='added',
|
id, href = self.oeb.manifest.generate(id='added', href=sanitize_file_name(bhref))
|
||||||
href=bhref)
|
|
||||||
guessed = self.guess_type(href)[0]
|
guessed = self.guess_type(href)[0]
|
||||||
media_type = guessed or self.BINARY_MIME
|
media_type = guessed or self.BINARY_MIME
|
||||||
if media_type == 'text/plain':
|
if media_type == 'text/plain':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user