Better image extension regexes, so we don't just grab the "jpe" from "jpeg" files in media_sideload_image(). props sivel. fixes #16693

git-svn-id: http://core.svn.wordpress.org/trunk@21219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2012-07-05 20:51:55 +00:00
parent e7b985db6f
commit 6a1d888ea5
3 changed files with 3 additions and 3 deletions

View File

@ -599,7 +599,7 @@ function media_sideload_image($file, $post_id, $desc = null) {
// Set variables for storage
// fix file filename for query strings
preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
$file_array['name'] = basename($matches[0]);
$file_array['tmp_name'] = $tmp;

View File

@ -172,7 +172,7 @@ if ( !empty($_REQUEST['ajax']) ) {
*/
function get_images_from_uri($uri) {
$uri = preg_replace('/\/#.+?$/','', $uri);
if ( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
if ( preg_match( '/\.(jpe?g|jpe|gif|png)\b/i', $uri ) && !strpos( $uri, 'blogger.com' ) )
return "'" . esc_attr( html_entity_decode($uri) ) . "'";
$content = wp_remote_fopen($uri);
if ( false === $content )

View File

@ -4036,7 +4036,7 @@ function wp_attachment_is_image( $post_id = 0 ) {
$ext = preg_match('/\.([^.]+)$/', $file, $matches) ? strtolower($matches[1]) : false;
$image_exts = array('jpg', 'jpeg', 'gif', 'png');
$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import' == $post->post_mime_type && in_array($ext, $image_exts) )
return true;