Smush Image Compression and Optimization - Version 1.6.5.3

Version Description

  • Removed check for file within local site home path.
Download this release

Release Info

Developer WPMUDEV
Plugin Icon 128x128 Smush Image Compression and Optimization
Version 1.6.5.3
Comparing to
See all releases

Code changes from version 1.6.5.2 to 1.6.5.3

Files changed (2) hide show
  1. readme.txt +5 -2
  2. wp-smushit.php +21 -15
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === WP Smush.it ===
2
  Plugin Name: WP Smush.it
3
- Version: 1.6.5.2
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: images, image, attachments, attachment, Smush.it
8
  Requires at least: 3.5
9
  Tested up to: 3.6
10
- Stable tag: 1.6.5.2
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
@@ -72,6 +72,9 @@ This will give us a good foundation to start adding some new features!
72
 
73
  == Changelog ==
74
 
 
 
 
75
  = 1.6.5.2 =
76
  * Corrected issues with Windows paths compare.
77
  * Added debug output option to help with user support issues.
1
  === WP Smush.it ===
2
  Plugin Name: WP Smush.it
3
+ Version: 1.6.5.3
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: images, image, attachments, attachment, Smush.it
8
  Requires at least: 3.5
9
  Tested up to: 3.6
10
+ Stable tag: 1.6.5.3
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
72
 
73
  == Changelog ==
74
 
75
+ = 1.6.5.3 =
76
+ * Removed check for file within local site home path.
77
+
78
  = 1.6.5.2 =
79
  * Corrected issues with Windows paths compare.
80
  * Added debug output option to help with user support issues.
wp-smushit.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Smush.it
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
6
  Author: WPMU DEV
7
- Version: 1.6.5.2
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp_smushit
10
  */
@@ -330,36 +330,42 @@ class WpSmushit {
330
  static $error_count = 0;
331
 
332
  if ( $error_count >= WP_SMUSHIT_ERRORS_BEFORE_QUITTING ) {
333
- return __( "Did not smush due to previous errors", WP_SMUSHIT_DOMAIN );
334
  }
335
 
336
  // check that the file exists
337
  if ( !file_exists( $file_path ) || !is_file( $file_path ) ) {
338
- return sprintf( __( "Could not find <span class='code'>%s</span>", WP_SMUSHIT_DOMAIN ), $file_path );
339
  }
340
 
341
  // check that the file is writable
342
  if ( !is_writable( dirname( $file_path)) ) {
343
- return sprintf( __("<span class='code'>%s</span> is not writable", WP_SMUSHIT_DOMAIN ), dirname($file_path) );
344
  }
345
 
346
  $file_size = filesize( $file_path );
347
  if ( $file_size > WP_SMUSHIT_MAX_BYTES ) {
348
- return sprintf(__('<span style="color:#FF0000;">Skipped (%s) Unable to Smush due to Yahoo 1mb size limits. See <a href="http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict">FAQ</a></span>', WP_SMUSHIT_DOMAIN), $this->format_bytes($file_size));
349
  }
350
 
 
 
 
351
  // check that the file is within the WP_CONTENT_DIR
352
  // But first convert the slashes to be uniform. Really with WP would already do this!
353
- $file_path_tmp = str_replace('\\', '/', realpath($file_path));
354
- $ABSPATH_tmp = str_replace('\\', '/', ABSPATH);
355
- if (WP_SMUSHIT_DEBUG) {
356
- echo "DEBUG: file_path [". $file_path_tmp ."] ABSPATH [". $ABSPATH_tmp ."]<br />";
 
 
357
  }
358
- if (stripos( $file_path_tmp, $ABSPATH_tmp) !== 0) {
359
- return sprintf( __( "<span class='code'>%s</span> must be within the website directory (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ),
360
- htmlentities( $file_path_tmp ), $ABSPATH_tmp);
 
361
  }
362
-
363
  // The Yahoo! Smush.it service does not working with https images.
364
  $file_url = str_replace('https://', 'http://', $file_url);
365
  $home_url = str_replace('https://', 'http://', get_option('home'));
@@ -368,7 +374,7 @@ class WpSmushit {
368
  }
369
 
370
  if (stripos($file_url, $home_url) !== 0) {
371
- return sprintf( __( "<span class='code'>%s</span> must be within the website home URL (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ),
372
  htmlentities( $file_url ), $home_url);
373
  }
374
 
@@ -379,7 +385,7 @@ class WpSmushit {
379
 
380
  if ( false === $data ) {
381
  $error_count++;
382
- return __( 'Error posting to Smush.it', WP_SMUSHIT_DOMAIN );
383
  }
384
 
385
  // make sure the response looks like JSON -- added 2008-12-19 when
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes and improve performance using the <a href="http://smush.it/">Smush.it</a> API within WordPress.
6
  Author: WPMU DEV
7
+ Version: 1.6.5.3
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp_smushit
10
  */
330
  static $error_count = 0;
331
 
332
  if ( $error_count >= WP_SMUSHIT_ERRORS_BEFORE_QUITTING ) {
333
+ return __( "Did not Smush.it due to previous errors", WP_SMUSHIT_DOMAIN );
334
  }
335
 
336
  // check that the file exists
337
  if ( !file_exists( $file_path ) || !is_file( $file_path ) ) {
338
+ return sprintf( __( "ERROR: Could not find <span class='code'>%s</span>", WP_SMUSHIT_DOMAIN ), $file_path );
339
  }
340
 
341
  // check that the file is writable
342
  if ( !is_writable( dirname( $file_path)) ) {
343
+ return sprintf( __("ERROR: <span class='code'>%s</span> is not writable", WP_SMUSHIT_DOMAIN ), dirname($file_path) );
344
  }
345
 
346
  $file_size = filesize( $file_path );
347
  if ( $file_size > WP_SMUSHIT_MAX_BYTES ) {
348
+ return sprintf(__('ERROR: <span style="color:#FF0000;">Skipped (%s) Unable to Smush due to Yahoo 1mb size limits. See <a href="http://developer.yahoo.com/yslow/smushit/faq.html#faq_restrict">FAQ</a></span>', WP_SMUSHIT_DOMAIN), $this->format_bytes($file_size));
349
  }
350
 
351
+ // local file check disabled 2013-09-05 - I don't see a point in checking this. We only use the URL of the file to Yahoo! and there is no gaurentee
352
+ // the file path is the SAME as the image from the URL. We can only really make sure the image URL starts with the home URL. This should prevent CDN URLs
353
+ // from being processed.
354
  // check that the file is within the WP_CONTENT_DIR
355
  // But first convert the slashes to be uniform. Really with WP would already do this!
356
+ /*
357
+ $file_path_tmp = str_replace('\\', '/', $file_path);
358
+ $WP_CONTENT_DIR_tmp = str_replace('\\', '/', WP_CONTENT_DIR);
359
+
360
+ if (WP_SMUSHIT_DEBUG) {
361
+ echo "DEBUG: file_path [". $file_path_tmp ."] WP_CONTENT_DIR [". $WP_CONTENT_DIR_tmp ."]<br />";
362
  }
363
+ if (stripos( $file_path_tmp, $WP_CONTENT_DIR_tmp) !== 0) {
364
+ return sprintf( __( "ERROR: <span class='code'>%s</span> must be within the website content directory (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ),
365
+ htmlentities( $file_path_tmp ), $WP_CONTENT_DIR_tmp);
366
+ }
367
  }
368
+ */
369
  // The Yahoo! Smush.it service does not working with https images.
370
  $file_url = str_replace('https://', 'http://', $file_url);
371
  $home_url = str_replace('https://', 'http://', get_option('home'));
374
  }
375
 
376
  if (stripos($file_url, $home_url) !== 0) {
377
+ return sprintf( __( "ERROR: <span class='code'>%s</span> must be within the website home URL (<span class='code'>%s</span>)", WP_SMUSHIT_DOMAIN ),
378
  htmlentities( $file_url ), $home_url);
379
  }
380
 
385
 
386
  if ( false === $data ) {
387
  $error_count++;
388
+ return __( 'ERROR: posting to Smush.it', WP_SMUSHIT_DOMAIN );
389
  }
390
 
391
  // make sure the response looks like JSON -- added 2008-12-19 when