Skip to content

Commit

Permalink
Fix ValidatorTrait for SVG logos
Browse files Browse the repository at this point in the history
  • Loading branch information
JanOppolzer committed May 9, 2024
1 parent aa39fa1 commit a7595b5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/Traits/ValidatorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,16 @@ public function checkUIInfo(object $xpath): void
if (! $file) {
$this->error .= $SSODescriptor.'/UIInfo/Logo '.$logo->nodeValue.' could not be read. ';
} else {
if (str_ends_with($logo->nodeValue, '.svg')) {
$doc = new \DOMDocument();
$doc->load($logo->nodeValue);
if (strcmp($doc->documentElement->nodeName, 'svg') !== 0) {
$this->error .= $SSODescriptor.'/UIInfo/Logo '.$logo->nodeValue.' is not an image. ';
} else {
return;
}
}

if (exif_imagetype($logo->nodeValue)) {
$imagesize = getimagesize($logo->nodeValue);
$img_width = $imagesize[0];
Expand All @@ -424,14 +434,6 @@ public function checkUIInfo(object $xpath): void
$this->error .= $SSODescriptor.'/UIInfo/Logo[@height="'.$md_height.'"] does not match the height ('.$img_height.'px) of the image '.$logo->nodeValue.'. ';
}
}

if (! exif_imagetype($logo->nodeValue)) {
$doc = new \DOMDocument();
$doc->load($logo->nodeValue);
if (strcmp($doc->documentElement->nodeName, 'svg') !== 0) {
$this->error .= $SSODescriptor.'/UIInfo/Logo '.$logo->nodeValue.' is not an image. ';
}
}
}
}
}
Expand Down

0 comments on commit a7595b5

Please sign in to comment.