Skip to content

Commit

Permalink
Merge pull request #186 from 10up/fix/184
Browse files Browse the repository at this point in the history
Ensure the svg file loads properly before we access it's properties
  • Loading branch information
dkotter authored Mar 26, 2024
2 parents d47a4a1 + 741cc55 commit 941da6c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,11 @@ protected function svg_dimensions( $attachment_id ) {
} elseif ( $svg ) {
$svg = @simplexml_load_file( $svg ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged

// Ensure the svg could be loaded.
if ( ! $svg ) {
return false;
}

$attributes = $svg->attributes();

if ( isset( $attributes->viewBox ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
Expand Down

0 comments on commit 941da6c

Please sign in to comment.