From a7aff82a713505400d4537de89c1d68e36c23b57 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sun, 29 Jul 2018 14:52:47 +0200 Subject: [PATCH] Handle unsupported image formats better in htmlfix If Image::Size::imgsize returns undefined width/height, don't attempt to use those values, just bail out. --- src/wml_backend/p7_htmlfix/htmlfix.src | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wml_backend/p7_htmlfix/htmlfix.src b/src/wml_backend/p7_htmlfix/htmlfix.src index 87a8a5e6..0724ef60 100644 --- a/src/wml_backend/p7_htmlfix/htmlfix.src +++ b/src/wml_backend/p7_htmlfix/htmlfix.src @@ -144,8 +144,9 @@ sub ProcessImgTag { } if ($width eq '*' or $width == -1 or $height eq '*' or $height == -1 ) { - if (-f $image) { - ($Pwidth, $Pheight) = Image::Size::imgsize($image); + my $error; + ($Pwidth, $Pheight, $error) = Image::Size::imgsize($image); + if (defined($Pwidth) and defined($Pheight)) { # width given, height needs completed if ((not ($width eq '*' or $width == -1)) and @@ -200,7 +201,7 @@ sub ProcessImgTag { } else { # complain - verbose("cannot complete size of $image: file not found"); + verbose("cannot complete size of $image: $error"); # and make sure the =* placeholder constructs are removed $attr =~ s|WIDTH\s*=\s*\*||is; $attr =~ s|HEIGHT\s*=\s*\*||is;