Make WordPress Core

Ticket #18412: 18412.2.diff

File 18412.2.diff, 1.5 KB (added by c3mdigital, 11 years ago)

Refresh of existing patch

  • wp-includes/post.php

     
    41964196        if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recommended to rely upon this.
    41974197                $url = get_the_guid( $post->ID );
    41984198
    4199         $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
     4199        $url = apply_filters( 'wp_get_attachment_url', wp_double_encode_url( $url ), $post->ID );
    42004200
    42014201        if ( empty( $url ) )
    42024202                return false;
     
    42054205}
    42064206
    42074207/**
     4208 * Double encode any accidental %xx combinations in the filename (e.g. My%20Picture.jpg)
     4209 *
     4210 * @since 3.7
     4211 * @param string $url
     4212 *
     4213 * @return string
     4214 */
     4215function wp_double_encode_url( $url ) {
     4216        return preg_replace( '/%\d\d/e', "rawurlencode(rawurlencode(urldecode('$0')))", $url );
     4217}
     4218/**
    42084219 * Retrieve thumbnail for an attachment.
    42094220 *
    42104221 * @since 2.1.0
  • wp-includes/media.php

     
    174174                // we have the actual image size, but might need to further constrain it if content_width is narrower
    175175                list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
    176176
    177                 return array( $img_url, $width, $height, $is_intermediate );
     177                return array( wp_double_encode_url( $img_url ), $width, $height, $is_intermediate );
    178178        }
    179179        return false;
    180180