Merge pull request #6403 from tk0miya/6402_unknown_image

Fix #6402: image directive crashes by unknown image format
This commit is contained in:
Takeshi KOMIYA 2019-05-30 01:30:33 +09:00 committed by GitHub
commit 29336e6c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -130,6 +130,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: