WebP Express - Version 0.22.1

Version Description

(released: 09 Nov 2021) * Bugfix: Old unupdated rewrite rules for redirecting to converter caused error (bug was introduced in 0.22.0). Thanks, @utrenkner for reacting quickly! * Bugfix: Backslashes in file paths in .htaccess on Windows caused redirecting not to work. Thanks to Herb Miller (@bobbingwide) from UK for discovering and debugging this.

Download this release

Release Info

Developer rosell.dk
Plugin Icon 128x128 WebP Express
Version 0.22.1
Comparing to
See all releases

Code changes from version 0.22.0 to 0.22.1

README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://ko-fi.com/rosell
4
  Tags: webp, images, performance
5
  Requires at least: 4.0
6
  Tested up to: 5.8
7
- Stable tag: 0.22.0
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -175,6 +175,7 @@ Bread on the table don't come for free, even though this plugin does, and always
175
  * Ruben Solvang
176
 
177
  **Persons who recently contributed with [ko-fi](https://ko-fi.com/rosell) - Thanks!**
 
178
  * 26 Oct: Anonymous
179
  * 29 Aug: Pawa Tecnologia
180
  * 29 Jul: Brian Laursen
@@ -775,6 +776,11 @@ If you want to make sure that my coffee supplies don't run dry, you can even buy
775
 
776
  == Changelog ==
777
 
 
 
 
 
 
778
  = 0.22.0 =
779
  *(released: 09 Nov 2021)*
780
  * Added option to disable creating log files and button to do delete them. Thanks to Amit Sonkhiya and many others for suggesting this.
@@ -828,6 +834,9 @@ For older releases, check out changelog.txt
828
 
829
  == Upgrade Notice ==
830
 
 
 
 
831
  = 0.22.0 =
832
  * Various improvements and bug fixes
833
 
4
  Tags: webp, images, performance
5
  Requires at least: 4.0
6
  Tested up to: 5.8
7
+ Stable tag: 0.22.1
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
175
  * Ruben Solvang
176
 
177
  **Persons who recently contributed with [ko-fi](https://ko-fi.com/rosell) - Thanks!**
178
+ * 9 Nov: @utrenkner
179
  * 26 Oct: Anonymous
180
  * 29 Aug: Pawa Tecnologia
181
  * 29 Jul: Brian Laursen
776
 
777
  == Changelog ==
778
 
779
+ = 0.22.1 =
780
+ *(released: 09 Nov 2021)*
781
+ * Bugfix: Old unupdated rewrite rules for redirecting to converter caused error (bug was introduced in 0.22.0). Thanks, @utrenkner for reacting quickly!
782
+ * Bugfix: Backslashes in file paths in .htaccess on Windows caused redirecting not to work. Thanks to Herb Miller (@bobbingwide) from UK for discovering and debugging this.
783
+
784
  = 0.22.0 =
785
  *(released: 09 Nov 2021)*
786
  * Added option to disable creating log files and button to do delete them. Thanks to Amit Sonkhiya and many others for suggesting this.
834
 
835
  == Upgrade Notice ==
836
 
837
+ = 0.22.1 =
838
+ * Two bug fixes related to .htaccess files and redirecting to converter
839
+
840
  = 0.22.0 =
841
  * Various improvements and bug fixes
842
 
changelog.txt CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  = 0.22.0 =
2
  *(released: 09 Nov 2021)*
3
  * Added option to disable creating log files and button to do delete them. Thanks to Amit Sonkhiya and many others for suggesting this.
1
+ = 0.22.1 =
2
+ *(released: 09 Nov 2021)*
3
+ * Bugfix: Old unupdated rewrite rules for redirecting to converter caused error (bug was introduced in 0.22.0). Thanks, @utrenkner for reacting quickly!
4
+ * Bugfix: Backslashes in file paths in .htaccess on Windows caused redirecting not to work. Thanks to Herb Miller (@bobbingwide) from UK for discovering and debugging this.
5
+
6
  = 0.22.0 =
7
  *(released: 09 Nov 2021)*
8
  * Added option to disable creating log files and button to do delete them. Thanks to Amit Sonkhiya and many others for suggesting this.
docs/publishing.md CHANGED
@@ -114,12 +114,12 @@ svn status | grep '^!' | awk '{print $2}' | xargs svn delete --force (t
114
  Then add a new tag
115
  ```
116
  cd svn
117
- svn cp trunk tags/0.21.1 (this will copy trunk into a new tag)
118
  ```
119
 
120
  And commit!
121
  ```
122
- svn ci -m '0.21.1'
123
  ```
124
 
125
 
114
  Then add a new tag
115
  ```
116
  cd svn
117
+ svn cp trunk tags/0.22.0 (this will copy trunk into a new tag)
118
  ```
119
 
120
  And commit!
121
  ```
122
+ svn ci -m '0.22.0'
123
  ```
124
 
125
 
lib/classes/ConvertHelperIndependent.php CHANGED
@@ -571,7 +571,7 @@ APACHE
571
  $text = preg_replace('#' . preg_quote($_SERVER["DOCUMENT_ROOT"]) . '#', '[doc-root]', $text);
572
 
573
  // TODO: Put version number somewhere else. Ie \WebPExpress\VersionNumber::version
574
- $text = 'WebP Express 0.22.0. ' . $msgTop . ', ' . date("Y-m-d H:i:s") . "\n\r\n\r" . $text;
575
 
576
  $logFile = self::getLogFilename($source, $logDir);
577
 
571
  $text = preg_replace('#' . preg_quote($_SERVER["DOCUMENT_ROOT"]) . '#', '[doc-root]', $text);
572
 
573
  // TODO: Put version number somewhere else. Ie \WebPExpress\VersionNumber::version
574
+ $text = 'WebP Express 0.22.1. ' . $msgTop . ', ' . date("Y-m-d H:i:s") . "\n\r\n\r" . $text;
575
 
576
  $logFile = self::getLogFilename($source, $logDir);
577
 
lib/classes/HTAccessRules.php CHANGED
@@ -374,7 +374,9 @@ class HTAccessRules
374
  $cacheDirRel = Paths::getCacheDirRelToDocRoot() . '/doc-root';
375
 
376
  $rules .= " RewriteCond %{REQUEST_FILENAME} -f\n";
377
- $rules .= " RewriteCond " . self::$docRootString . "/" . $cacheDirRel . "/" . self::$htaccessDirRelToDocRoot . "/$1.$2.webp -f\n";
 
 
378
  $rules .= " RewriteRule ^/?(.+)\.(" . self::$fileExt . ")$ /" . $cacheDirRel . "/" . self::$htaccessDirRelToDocRoot .
379
  "/$1.$2.webp [NC,T=image/webp,E=EXISTING:1," . (self::$setAddVaryEnvInRedirect ? 'E=ADDVARY:1,' : '') . "L]\n\n";
380
 
@@ -392,7 +394,7 @@ class HTAccessRules
392
  self::$htaccessDir
393
  );
394
  $cacheDirForThisRoot = PathHelper::fixAbsPathToUseUnresolvedDocRoot($cacheDirForThisRoot);
395
-
396
  $rules .= " RewriteCond " . $cacheDirForThisRoot . "/%2%3.webp -f\n";
397
  //RewriteCond /var/www/webp-express-tests/we0/wp-content-moved/webp-express/webp-images/uploads/%2%3.webp -f
398
 
@@ -1075,7 +1077,9 @@ class HTAccessRules
1075
  Paths::getBiggerThanSourceDirAbs() . '/' . self::$htaccessDir
1076
  );
1077
  $rules .= " RewriteCond " .
1078
- self::replaceDocRootWithApacheTokenIfDocRootAvailable($cacheDirForThisRoot) .
 
 
1079
  "/%2%3.webp -f\n";
1080
 
1081
  $rules .= " RewriteRule . - [L]\n\n";
374
  $cacheDirRel = Paths::getCacheDirRelToDocRoot() . '/doc-root';
375
 
376
  $rules .= " RewriteCond %{REQUEST_FILENAME} -f\n";
377
+ $rules .= " RewriteCond " .
378
+ self::$docRootString .
379
+ "/" . $cacheDirRel . "/" . self::$htaccessDirRelToDocRoot . "/$1.$2.webp -f\n";
380
  $rules .= " RewriteRule ^/?(.+)\.(" . self::$fileExt . ")$ /" . $cacheDirRel . "/" . self::$htaccessDirRelToDocRoot .
381
  "/$1.$2.webp [NC,T=image/webp,E=EXISTING:1," . (self::$setAddVaryEnvInRedirect ? 'E=ADDVARY:1,' : '') . "L]\n\n";
382
 
394
  self::$htaccessDir
395
  );
396
  $cacheDirForThisRoot = PathHelper::fixAbsPathToUseUnresolvedDocRoot($cacheDirForThisRoot);
397
+ $cacheDirForThisRoot = PathHelper::backslashesToForwardSlashes($cacheDirForThisRoot); #512
398
  $rules .= " RewriteCond " . $cacheDirForThisRoot . "/%2%3.webp -f\n";
399
  //RewriteCond /var/www/webp-express-tests/we0/wp-content-moved/webp-express/webp-images/uploads/%2%3.webp -f
400
 
1077
  Paths::getBiggerThanSourceDirAbs() . '/' . self::$htaccessDir
1078
  );
1079
  $rules .= " RewriteCond " .
1080
+ PathHelper::backslashesToForwardSlashes(
1081
+ self::replaceDocRootWithApacheTokenIfDocRootAvailable($cacheDirForThisRoot)
1082
+ ) .
1083
  "/%2%3.webp -f\n";
1084
 
1085
  $rules .= " RewriteRule . - [L]\n\n";
lib/classes/PathHelper.php CHANGED
@@ -364,10 +364,15 @@ class PathHelper
364
  //return preg_replace('/\/$/', '', $str);
365
  }
366
 
367
- // Canonicalize a path by resolving '../' and './'
 
 
 
 
368
  // Got it from a comment here: http://php.net/manual/en/function.realpath.php
369
  // But fixed it (it could not handle './../')
370
  public static function canonicalize($path) {
 
371
  $parts = explode('/', $path);
372
 
373
  // Remove parts containing just '.' (and the empty holes afterwards)
364
  //return preg_replace('/\/$/', '', $str);
365
  }
366
 
367
+ public static function backslashesToForwardSlashes($path) {
368
+ return str_replace( "\\", '/', $path);
369
+ }
370
+
371
+ // Canonicalize a path by resolving '../' and './'. It also replaces backslashes with forward slash
372
  // Got it from a comment here: http://php.net/manual/en/function.realpath.php
373
  // But fixed it (it could not handle './../')
374
  public static function canonicalize($path) {
375
+
376
  $parts = explode('/', $path);
377
 
378
  // Remove parts containing just '.' (and the empty holes afterwards)
lib/classes/WodConfigLoader.php CHANGED
@@ -148,7 +148,7 @@ class WodConfigLoader
148
  throw new \Exception('Path to wp-content was not received in any way');
149
  }
150
  }
151
- $wpContentDirRelToWEPluginDir = $wpContentDirRelToPluginDir . '/webp-express';
152
  }
153
 
154
 
148
  throw new \Exception('Path to wp-content was not received in any way');
149
  }
150
  }
151
+ $wpContentDirRelToWEPluginDir = $wpContentDirRelToPluginDir . '..';
152
  }
153
 
154
 
webp-express.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WebP Express
4
  * Plugin URI: https://github.com/rosell-dk/webp-express
5
  * Description: Serve autogenerated WebP images instead of jpeg/png to browsers that supports WebP. Works on anything (media library images, galleries, theme images etc).
6
- * Version: 0.22.0
7
  * Author: Bjørn Rosell
8
  * Author URI: https://www.bitwise-it.dk
9
  * License: GPL2
3
  * Plugin Name: WebP Express
4
  * Plugin URI: https://github.com/rosell-dk/webp-express
5
  * Description: Serve autogenerated WebP images instead of jpeg/png to browsers that supports WebP. Works on anything (media library images, galleries, theme images etc).
6
+ * Version: 0.22.1
7
  * Author: Bjørn Rosell
8
  * Author URI: https://www.bitwise-it.dk
9
  * License: GPL2