From 5abac389fabaf770173663f4a4de5d6cb6ce2ab1 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 6 Mar 2015 02:03:27 +0000 Subject: [PATCH] PressThis: when server-side parsing, filter small images by the width and height attributes if set. See #31373. Built from https://develop.svn.wordpress.org/trunk@31637 git-svn-id: http://core.svn.wordpress.org/trunk@31618 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-press-this.php | 12 ++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-wp-press-this.php b/wp-admin/includes/class-wp-press-this.php index be62992319..3084ce3a7c 100644 --- a/wp-admin/includes/class-wp-press-this.php +++ b/wp-admin/includes/class-wp-press-this.php @@ -285,10 +285,12 @@ class WP_Press_This { // Get the content of the source page from the tmp file.. $source_content = wp_kses( - file_get_contents( $source_tmp_file ), + @file_get_contents( $source_tmp_file ), array( 'img' => array( 'src' => array(), + 'width' => array(), + 'height' => array(), ), 'iframe' => array( 'src' => array(), @@ -529,7 +531,13 @@ class WP_Press_This { $items = $this->_limit_array( $matches[0] ); foreach ( $items as $value ) { - if ( preg_match( '/src=(\'|")([^\'"]+)\\1/', $value, $new_matches ) ) { + if ( ( preg_match( '/width=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 256 ) || + ( preg_match( '/height=(\'|")(\d+)\\1/i', $value, $new_matches ) && $new_matches[2] < 128 ) ) { + + continue; + } + + if ( preg_match( '/src=(\'|")([^\'"]+)\\1/i', $value, $new_matches ) ) { $src = $this->_limit_img( $new_matches[2] ); if ( ! empty( $src ) && ! in_array( $src, $data['_img'] ) ) { $data['_img'][] = $src; diff --git a/wp-includes/version.php b/wp-includes/version.php index 91b1de68c9..15bf170bf3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31636'; +$wp_version = '4.2-alpha-31637'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.