Media: Return early from media_sideload_image() if $file didn't match the pattern for images.

Props MikeHansenMe, serpent7776.
Fixes #32755.

git-svn-id: https://develop.svn.wordpress.org/trunk@34984 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-10-09 04:46:00 +00:00
parent 6350d90339
commit d58bcae1ad

View File

@ -847,6 +847,10 @@ function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' )
// Set variables for storage, fix file filename for query strings.
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
if ( ! $matches ) {
return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) );
}
$file_array = array();
$file_array['name'] = basename( $matches[0] );