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: https://develop.svn.wordpress.org/trunk@21219 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2012-07-05 20:51:55 +00:00
parent 757652fe01
commit 5ab7fcea5e
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;