Skip to content

Commit

Permalink
Merge pull request #1 from josephscott/fix/tonesque
Browse files Browse the repository at this point in the history
Check for image before calling imagecreatefromstring()
  • Loading branch information
josephscott authored Nov 16, 2023
2 parents bf9d7e8 + b5935a2 commit be902e5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion projects/plugins/jetpack/_inc/lib/tonesque.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public static function imagecreatefromurl( $image_url ) {

if ( empty( $data ) ) {
$response = wp_safe_remote_get( $image_url );
if ( is_wp_error( $response ) ) {
if (

Check failure on line 89 in projects/plugins/jetpack/_inc/lib/tonesque.php

View workflow job for this annotation

GitHub Actions / PHP Code Sniffer (non-excluded files only)

Whitespace found at end of line (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine)
is_wp_error( $response )
|| ! wp_startswith( $response['headers']['content-type'], 'image/' )
) {
return false;
}
$data = wp_remote_retrieve_body( $response );
Expand All @@ -103,6 +106,10 @@ public static function imagecreatefromurl( $image_url ) {
}
}

if ( null === $data ) {
return false;
}

// Now turn it into an image and return it.
return imagecreatefromstring( $data );
}
Expand Down

0 comments on commit be902e5

Please sign in to comment.