WebP Express - Version 0.14.14

Version Description

(released: 26 jun 2019)

  • Fixed errors on systems with symlinked folders
Download this release

Release Info

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

Code changes from version 0.14.13 to 0.14.14

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.2
7
- Stable tag: 0.14.13
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -605,6 +605,11 @@ Easy enough! - [Go here!](https://ko-fi.com/rosell). Or [here](https://buymeacof
605
 
606
  == Changelog ==
607
 
 
 
 
 
 
608
  = 0.14.13 =
609
  *(released: 26 jun 2019)*
610
 
@@ -864,6 +869,9 @@ For older releases, check out changelog.txt
864
 
865
  == Upgrade Notice ==
866
 
 
 
 
867
  = 0.14.13 =
868
  Fixed errors in conversion scripts
869
 
4
  Tags: webp, images, performance
5
  Requires at least: 4.0
6
  Tested up to: 5.2
7
+ Stable tag: 0.14.14
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
605
 
606
  == Changelog ==
607
 
608
+ = 0.14.14 =
609
+ *(released: 26 jun 2019)*
610
+
611
+ * Fixed errors on systems with symlinked folders
612
+
613
  = 0.14.13 =
614
  *(released: 26 jun 2019)*
615
 
869
 
870
  == Upgrade Notice ==
871
 
872
+ = 0.14.14 =
873
+ Fixed errors on systems with symlinked folders
874
+
875
  = 0.14.13 =
876
  Fixed errors in conversion scripts
877
 
lib/classes/ConvertHelperIndependent.php CHANGED
@@ -71,25 +71,34 @@ class ConvertHelperIndependent
71
  try {
72
  // Check source
73
  // --------------
74
- $source = SanityCheck::absPathExistsAndIsFileInDocRoot($source);
 
75
 
76
  // Calculate destination and check that the result is sane
77
  // -------------------------------------------------------
78
  if (self::storeMingledOrNot($source, $destinationFolder, $uploadDirAbs)) {
79
  if ($destinationExt == 'append') {
80
- $destination = SanityCheck::absPathIsInDocRoot($source . '.webp');
 
 
81
  } else {
82
  $destination = preg_replace('/\\.(jpe?g|png)$/', '', $source) . '.webp';
83
- $destination = SanityCheck::absPathIsInDocRoot($source . '.webp');
 
 
84
  }
85
  } else {
86
  $docRoot = rtrim(realpath($_SERVER["DOCUMENT_ROOT"]), '/');
87
  $imageRoot = $webExpressContentDirAbs . '/webp-images';
88
- SanityCheck::absPathIsInDocRoot($imageRoot);
 
 
89
 
90
  $sourceRel = substr($source, strlen($docRoot) + 1);
91
  $destination = $imageRoot . '/doc-root/' . $sourceRel . '.webp';
92
- $destination = SanityCheck::absPathIsInDocRoot($destination);
 
 
93
  }
94
 
95
  } catch (SanityException $e) {
@@ -320,7 +329,7 @@ APACHE
320
 
321
  $text = preg_replace('#' . preg_quote($_SERVER["DOCUMENT_ROOT"]) . '#', '[doc-root]', $text);
322
 
323
- $text = 'WebP Express 0.14.13. ' . $msgTop . ', ' . date("Y-m-d H:i:s") . "\n\r\n\r" . $text;
324
 
325
  $logFile = self::getLogFilename($source, $logDir);
326
 
71
  try {
72
  // Check source
73
  // --------------
74
+ // TODO: make this check work with symlinks
75
+ //$source = SanityCheck::absPathExistsAndIsFileInDocRoot($source);
76
 
77
  // Calculate destination and check that the result is sane
78
  // -------------------------------------------------------
79
  if (self::storeMingledOrNot($source, $destinationFolder, $uploadDirAbs)) {
80
  if ($destinationExt == 'append') {
81
+ // TODO: make this check work with symlinks
82
+ //$destination = SanityCheck::absPathIsInDocRoot($source . '.webp');
83
+ $destination = $source . '.webp';
84
  } else {
85
  $destination = preg_replace('/\\.(jpe?g|png)$/', '', $source) . '.webp';
86
+ // TODO: make this check work with symlinks
87
+ //$destination = SanityCheck::absPathIsInDocRoot($source . '.webp');
88
+ $destination = $source . '.webp';
89
  }
90
  } else {
91
  $docRoot = rtrim(realpath($_SERVER["DOCUMENT_ROOT"]), '/');
92
  $imageRoot = $webExpressContentDirAbs . '/webp-images';
93
+
94
+ // TODO: make this check work with symlinks
95
+ //SanityCheck::absPathIsInDocRoot($imageRoot);
96
 
97
  $sourceRel = substr($source, strlen($docRoot) + 1);
98
  $destination = $imageRoot . '/doc-root/' . $sourceRel . '.webp';
99
+
100
+ // TODO: make this check work with symlinks
101
+ //$destination = SanityCheck::absPathIsInDocRoot($destination);
102
  }
103
 
104
  } catch (SanityException $e) {
329
 
330
  $text = preg_replace('#' . preg_quote($_SERVER["DOCUMENT_ROOT"]) . '#', '[doc-root]', $text);
331
 
332
+ $text = 'WebP Express 0.14.14. ' . $msgTop . ', ' . date("Y-m-d H:i:s") . "\n\r\n\r" . $text;
333
 
334
  $logFile = self::getLogFilename($source, $logDir);
335
 
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.14.13
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.14.14
7
  * Author: Bjørn Rosell
8
  * Author URI: https://www.bitwise-it.dk
9
  * License: GPL2
wod/webp-on-demand.php CHANGED
@@ -51,21 +51,22 @@ class WebPOnDempand
51
 
52
  // Check input
53
  // --------------
54
-
55
  try {
56
 
57
  // Check DOCUMENT_ROOT
58
  // ----------------------
59
  $checking = 'DOCUMENT_ROOT';
60
  $docRoot = SanityCheck::absPath($_SERVER["DOCUMENT_ROOT"]);
 
 
61
 
62
  // Use realpath to expand symbolic links and check if it exists
63
- $docRoot = realpath($docRoot);
64
- if ($docRoot === false) {
65
  throw new SanityException('Cannot find document root');
66
  }
67
- $docRoot = rtrim($docRoot, '/');
68
- $docRoot = SanityCheck::absPathExistsAndIsDir($docRoot);
69
 
70
  // Check wp-content
71
  // ----------------------
@@ -125,7 +126,7 @@ class WebPOnDempand
125
  // Check if it is in an environment variable
126
  $source = self::getEnvPassedInRewriteRule('REQFN');
127
  if ($source !== false) {
128
- $source = SanityCheck::absPathExistsAndIsFileInDocRoot($source);
129
  } else {
130
  // Check if it is in header (but only if .htaccess was configured to send in header)
131
  if (isset($wodOptions['base-htaccess-on-these-capability-tests'])) {
@@ -138,7 +139,7 @@ class WebPOnDempand
138
  }
139
  if ((!$passThrougEnvVarDefinitelyAvailable) && (!$passThroughHeaderDefinitelyUnavailable)) {
140
  if (isset($_SERVER['HTTP_REQFN'])) {
141
- $source = SanityCheck::absPathExistsAndIsFileInDocRoot($_SERVER['HTTP_REQFN']);
142
  }
143
  } else {
144
  // Check querystring (relative path)
@@ -155,10 +156,10 @@ class WebPOnDempand
155
  (isset($_GET['source']) || isset($_GET['xsource']))
156
  ) {
157
  if (isset($_GET['source'])) {
158
- $source = SanityCheck::absPathExistsAndIsFileInDocRoot($_GET['source']);
159
  } else {
160
  $xsrc = SanityCheck::noControlChars($_GET['xsource']);
161
- $source = SanityCheck::absPathExistsAndIsFileInDocRoot(substr($xsrc, 1));
162
  }
163
  } else {
164
  // Last resort is to use $_SERVER['REQUEST_URI'], well knowing that it does not give the
@@ -169,7 +170,13 @@ class WebPOnDempand
169
  }
170
  }
171
  }
172
- $source = SanityCheck::pathBeginsWith($source, $docRoot . '/');
 
 
 
 
 
 
173
 
174
  // Check destination path
175
  // --------------------------------------------
@@ -181,6 +188,7 @@ class WebPOnDempand
181
  $webExpressContentDirAbs,
182
  $docRoot . '/' . $wodOptions['paths']['uploadDirRel']
183
  );
 
184
  $destination = SanityCheck::absPath($destination);
185
  $destination = SanityCheck::pregMatch('#\.webp$#', $destination, 'Does not end with .webp');
186
  $destination = SanityCheck::pathBeginsWith($destination, $docRoot . '/');
51
 
52
  // Check input
53
  // --------------
 
54
  try {
55
 
56
  // Check DOCUMENT_ROOT
57
  // ----------------------
58
  $checking = 'DOCUMENT_ROOT';
59
  $docRoot = SanityCheck::absPath($_SERVER["DOCUMENT_ROOT"]);
60
+ $docRoot = rtrim($docRoot, '/');
61
+ $docRoot = SanityCheck::absPathExistsAndIsDir($docRoot);
62
 
63
  // Use realpath to expand symbolic links and check if it exists
64
+ $docRootSymLinksExpanded = realpath($docRoot);
65
+ if ($docRootSymLinksExpanded === false) {
66
  throw new SanityException('Cannot find document root');
67
  }
68
+ $docRootSymLinksExpanded = rtrim($docRootSymLinksExpanded, '/');
69
+ $docRootSymLinksExpanded = SanityCheck::absPathExistsAndIsDir($docRootSymLinksExpanded);
70
 
71
  // Check wp-content
72
  // ----------------------
126
  // Check if it is in an environment variable
127
  $source = self::getEnvPassedInRewriteRule('REQFN');
128
  if ($source !== false) {
129
+ $source = SanityCheck::absPathExistsAndIsFile($source);
130
  } else {
131
  // Check if it is in header (but only if .htaccess was configured to send in header)
132
  if (isset($wodOptions['base-htaccess-on-these-capability-tests'])) {
139
  }
140
  if ((!$passThrougEnvVarDefinitelyAvailable) && (!$passThroughHeaderDefinitelyUnavailable)) {
141
  if (isset($_SERVER['HTTP_REQFN'])) {
142
+ $source = SanityCheck::absPathExistsAndIsFile($_SERVER['HTTP_REQFN']);
143
  }
144
  } else {
145
  // Check querystring (relative path)
156
  (isset($_GET['source']) || isset($_GET['xsource']))
157
  ) {
158
  if (isset($_GET['source'])) {
159
+ $source = SanityCheck::absPathExistsAndIsFile($_GET['source']);
160
  } else {
161
  $xsrc = SanityCheck::noControlChars($_GET['xsource']);
162
+ $source = SanityCheck::absPathExistsAndIsFile(substr($xsrc, 1));
163
  }
164
  } else {
165
  // Last resort is to use $_SERVER['REQUEST_URI'], well knowing that it does not give the
170
  }
171
  }
172
  }
173
+
174
+ // Make sure it is in doc root
175
+ try {
176
+ $source = SanityCheck::pathBeginsWith($source, $docRoot . '/');
177
+ } catch (SanityException $e) {
178
+ $source = SanityCheck::pathBeginsWith(realpath($source), $docRootSymLinksExpanded . '/');
179
+ }
180
 
181
  // Check destination path
182
  // --------------------------------------------
188
  $webExpressContentDirAbs,
189
  $docRoot . '/' . $wodOptions['paths']['uploadDirRel']
190
  );
191
+ //echo 'dest:' . $destination; exit;
192
  $destination = SanityCheck::absPath($destination);
193
  $destination = SanityCheck::pregMatch('#\.webp$#', $destination, 'Does not end with .webp');
194
  $destination = SanityCheck::pathBeginsWith($destination, $docRoot . '/');