From 95da3826b9cb30ada840d02519d4d857e2d0b03c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 9 Oct 2015 04:46:24 +0000 Subject: [PATCH] Media: Return early from `media_sideload_image()` if `$file` didn't match the pattern for images. Props MikeHansenMe, serpent7776. Fixes #32755. Built from https://develop.svn.wordpress.org/trunk@34984 git-svn-id: http://core.svn.wordpress.org/trunk@34949 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index c1f7f5f36e..904cbb0ebb 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -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] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 80dd6f6a5c..e283abc61c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34983'; +$wp_version = '4.4-alpha-34984'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.