diff --git a/projects/plugins/jetpack/_inc/lib/tonesque.php b/projects/plugins/jetpack/_inc/lib/tonesque.php index 1c974b20a8522..b674c260aa24d 100644 --- a/projects/plugins/jetpack/_inc/lib/tonesque.php +++ b/projects/plugins/jetpack/_inc/lib/tonesque.php @@ -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 ( + is_wp_error( $response ) + || ! wp_startswith( $response['headers']['content-type'], 'image/' ) + ) { return false; } $data = wp_remote_retrieve_body( $response ); @@ -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 ); }