oduwsdl/MementoEmbed

MementoEmbed fails to generate a data URI if original resource favicons are corrupted

Closed this issue · 0 comments

An exception is thrown if a favicon is corrupt and MementoEmbed attempts to convert it to a data URI:

Traceback (most recent call last):
  File "/Volumes/nerfherder External/Unsynced-Projects/MementoEmbed/mementoembed/services/memento.py", line 67, in originaldata
    originalresource.favicon, httpcache, 16, 16
  File "/Volumes/nerfherder External/Unsynced-Projects/MementoEmbed/mementoembed/imageselection.py", line 35, in convert_imageuri_to_pngdata_uri
    im = Image.open(ifp)
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2577, in open
    im = _open_core(fp, filename, prefix)
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2567, in _open_core
    im = factory(fp, filename)
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/ImageFile.py", line 102, in __init__
    self._open()
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 264, in _open
    self.load()
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 267, in load
    im = self.ico.getimage(self.size)
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 150, in getimage
    return self.frame(i)
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 226, in frame
    ('1;I', int(w/8), -1)  # 1bpp inverted, padded, reversed
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2403, in frombuffer
    return frombytes(mode, size, data, decoder_name, args)
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2336, in frombytes
    im.frombytes(data, decoder_name, args)
  File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 788, in frombytes
    raise ValueError("not enough image data")

Affected URI-Ms: