Skip to content
Permalink
Browse files

fixes #140, now corrupt original resource favicons generate blank dat…

…a URIs
  • Loading branch information...
shawnmjones committed Oct 22, 2018
1 parent 5c2a6a4 commit 7d3e49df37dac08f3e09a10d22c25607baba805f
@@ -11,3 +11,4 @@ dist
*.bak
node_modules
_build
working-dontcommit
@@ -26,7 +26,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '0.2018.10.13.195506'
release = '0.2018.10.22.185424'


# -- General configuration ---------------------------------------------------
@@ -32,8 +32,6 @@ def convert_imageuri_to_pngdata_uri(imageuri, httpcache, width, height=None):
else:
ifp = io.BytesIO(imagedata)

module_logger.debug("CONVERTING IMAGEURI TO PNGDATA URI")

im = Image.open(ifp)

im_width, im_height = im.size
@@ -61,9 +61,23 @@ def originaldata(urim, preferences):
originalresource = OriginalResource(memento, httpcache)

if preferences['datauri_favicon'].lower() == 'yes':
original_favicon = convert_imageuri_to_pngdata_uri(
originalresource.favicon, httpcache, 16, 16
)

try:
original_favicon = convert_imageuri_to_pngdata_uri(
originalresource.favicon, httpcache, 16, 16
)
except ValueError as e:

module_logger.exception(
"an error occurred while generating a data URI for an original resource favicon"
)

if str(e) == "not enough image data":
original_favicon=""

else:
raise e

else:
original_favicon = originalresource.favicon

@@ -107,9 +107,23 @@ def generate_socialcard_response(urim, preferences):
)

if preferences['datauri_favicon'].lower() == 'yes':
original_favicon_uri = convert_imageuri_to_pngdata_uri(
original_favicon_uri, httpcache, 16, 16
)
try:
original_favicon_uri = convert_imageuri_to_pngdata_uri(
original_favicon_uri, httpcache, 16, 16
)
except ValueError as e:

module_logger.exception(
"an error occurred while generating a data URI for an original resource favicon"
)

if str(e) == "not enough image data":
module_logger.error("the original favicon URI is being replaced with blank")
original_favicon_uri=""

else:
raise e

archive_favicon_uri = convert_imageuri_to_pngdata_uri(
archive_favicon_uri, httpcache, 16, 16
)
@@ -1,3 +1,3 @@
__appname__ = "MementoEmbed"
__appversion__ = '0.2018.10.13.195506'
__appversion__ = '0.2018.10.22.185424'
__useragent__ = "{}/{}".format(__appname__, __appversion__)

0 comments on commit 7d3e49d

Please sign in to comment.
You can’t perform that action at this time.