Fix #6402: image directive crashes by unknown image format

This commit is contained in:
Takeshi KOMIYA
2019-05-28 21:33:56 +09:00
parent eea9fbbdae
commit 3456ea7a72
2 changed files with 4 additions and 0 deletions

View File

@@ -129,6 +129,7 @@ Bugs fixed
* #6378: linkcheck: Send commonly used User-Agent
* #6387: html search: failed to search document with haiku and scrolls themes
* #6406: Wrong year is returned for ``SOURCE_DATE_EPOCH``
* #6402: image directive crashes by unknown image format
Testing
--------

View File

@@ -100,6 +100,9 @@ class ImageCollector(EnvironmentCollector):
filename)
try:
mimetype = guess_mimetype(filename)
if mimetype is None:
basename, suffix = path.splitext(filename)
mimetype = 'image/x-' + suffix[1:]
if mimetype not in candidates:
globbed.setdefault(mimetype, []).append(new_imgpath)
except OSError as err: