diff --git a/web/validator-check-logos.php b/web/validator-check-logos.php index 0300b5409f95347a86104bc6590be7f18b2503cb..058323755f106543ef5a0fde0c508bc44aa9522f 100644 --- a/web/validator-check-logos.php +++ b/web/validator-check-logos.php @@ -104,15 +104,30 @@ foreach ($_POST as $k=>$v) { } else { $result[] = 'OKLOCAL'; } + $skipcheck = false; if ($suffix == 'svg') { - $xmlget = simplexml_load_string($imageData); - $xmlattributes = $xmlget->attributes(); + try { + $xmlget = simplexml_load_string($imageData); + if ($xmlget !== false) { + $xmlattributes = $xmlget->attributes(); + } else { + $result[] = "ERROR: not SVG image"; + $xmlattributes = NULL; + $skipcheck = true; + } + } catch (Exception $e) { + $result[] = "ERROR: not SVG image"; + $skipcheck = true; + } + if ($xmlattributes) { $width = $xmlattributes->width; $height = $xmlattributes->height; - $size = array($width, $hight); + $size = array($width, $height); + } } else { $size = getimagesize($fileName); } + if (!$skipcheck) { if ($size === false && !preg_match('/\.svg$/i', $limg)) { $result[] = "ERROR: The downloaded logo does not seem to be a PNG, JPG, GIF, SVG or a generally accepted image file format. Therefore, it most probably will not be displayed by web browsers."; } @@ -132,6 +147,7 @@ foreach ($_POST as $k=>$v) { if ($width && $height && isset($size[0]) && isset($size[1]) && round(10*$width/$height) != round(10*$size[0]/$size[1])) { $result[] = "WARNING: Mismatching proportions (".$width.'px:'.$height."px=".round($width/$height,1)." in metadata vs ".$size[0].'px:'.$size[1].'px='.round($size[0]/$size[1],1)." actual). The logo will be displayed distorted by Discovery Services and Service Providers."; } + } $res = array('result' => '', 'url' => ''); if ($remote != '') { $res['url'] = $remote;