mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 08:33:35 +01:00
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:
parent
6350d90339
commit
d58bcae1ad
@ -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] );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user