WordPress.org

Make WordPress Core

Changeset 21219


Ignore:
Timestamp:
07/05/2012 08:51:55 PM (7 years ago)
Author:
markjaquith
Message:

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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r21171 r21219  
    600600        // Set variables for storage
    601601        // fix file filename for query strings
    602         preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
     602        preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
    603603        $file_array['name'] = basename($matches[0]);
    604604        $file_array['tmp_name'] = $tmp;
  • trunk/wp-admin/press-this.php

    r21204 r21219  
    173173        function get_images_from_uri($uri) {
    174174            $uri = preg_replace('/\/#.+?$/','', $uri);
    175             if ( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
     175            if ( preg_match( '/\.(jpe?g|jpe|gif|png)\b/i', $uri ) && !strpos( $uri, 'blogger.com' ) )
    176176                return "'" . esc_attr( html_entity_decode($uri) ) . "'";
    177177            $content = wp_remote_fopen($uri);
  • trunk/wp-includes/post.php

    r21213 r21219  
    40374037    $ext = preg_match('/\.([^.]+)$/', $file, $matches) ? strtolower($matches[1]) : false;
    40384038
    4039     $image_exts = array('jpg', 'jpeg', 'gif', 'png');
     4039    $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
    40404040
    40414041    if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import' == $post->post_mime_type && in_array($ext, $image_exts) )
Note: See TracChangeset for help on using the changeset viewer.