Version Description
(released 23 May 2022) * When using the "Prevent using webps larger than original" with Alter HTML (picture tags) on images with srcset, those webps that where larger than the originals was picked out from the srcset for the webp. This could lead to bad quality images. In the fix, the image will only have a webp source alternative when ALL the webps are smaller than their originals (when the "prevent..." option is set). * Bugfix: In rare cases, WebP Express could fail detecting mime type
Download this release
Release Info
Developer | rosell.dk |
Plugin | WebP Express |
Version | 0.25.5 |
Comparing to | |
See all releases |
Code changes from version 0.25.4 to 0.25.5
- README.txt +9 -88
- changelog.txt +6 -0
- composer.json +2 -2
- docs/publishing.md +2 -2
- lib/classes/ConvertHelperIndependent.php +1 -1
- lib/classes/WebPOnDemand.php +7 -1
- lib/options/options/general/prevent-using-webps-larger-than-original.inc +9 -1
- vendor/composer/autoload_classmap.php +7 -3
- vendor/composer/autoload_psr4.php +3 -0
- vendor/composer/autoload_static.php +28 -3
- vendor/composer/installed.json +255 -15
- vendor/composer/installed.php +35 -8
- vendor/rosell-dk/file-util/LICENSE +9 -0
- vendor/rosell-dk/file-util/README.md +22 -0
- vendor/rosell-dk/file-util/composer.json +69 -0
- vendor/rosell-dk/file-util/phpcs-ruleset.xml +8 -0
- vendor/rosell-dk/{webp-convert/src/Helpers → file-util/src}/FileExists.php +10 -36
- vendor/rosell-dk/file-util/src/FileExistsUsingExec.php +40 -0
- vendor/rosell-dk/file-util/src/PathValidator.php +70 -0
- vendor/rosell-dk/image-mime-type-guesser/README.md +15 -5
- vendor/rosell-dk/image-mime-type-guesser/composer.json +13 -6
- vendor/rosell-dk/image-mime-type-guesser/phpcs-ruleset.xml +8 -0
- vendor/rosell-dk/image-mime-type-guesser/phpstan.neon +4 -0
- vendor/rosell-dk/image-mime-type-guesser/phpunit.xml.dist +0 -6
- vendor/rosell-dk/image-mime-type-guesser/src/Detectors/AbstractDetector.php +0 -1
- vendor/rosell-dk/image-mime-type-guesser/src/Detectors/SignatureSniffer.php +28 -0
- vendor/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php +1 -1
- vendor/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php +1 -35
- vendor/rosell-dk/image-mime-type-guesser/src/MimeMap.php +77 -0
- vendor/rosell-dk/image-mime-type-sniffer/LICENSE +9 -0
- vendor/rosell-dk/image-mime-type-sniffer/README.md +65 -0
- vendor/rosell-dk/image-mime-type-sniffer/composer.json +63 -0
- vendor/rosell-dk/image-mime-type-sniffer/phpcs-ruleset.xml +8 -0
- vendor/rosell-dk/image-mime-type-sniffer/phpunit.xml.dist +8 -0
- vendor/rosell-dk/{image-mime-type-guesser/src/Detectors/SniffFirstFourBytes.php → image-mime-type-sniffer/src/ImageMimeTypeSniffer.php} +61 -28
- vendor/rosell-dk/locate-binaries/LICENSE +9 -0
- vendor/rosell-dk/locate-binaries/README.md +39 -0
- vendor/rosell-dk/locate-binaries/composer.json +69 -0
- vendor/rosell-dk/locate-binaries/phpcs-ruleset.xml +8 -0
- vendor/rosell-dk/locate-binaries/src/LocateBinaries.php +163 -0
- vendor/rosell-dk/webp-convert/README.md +1 -0
- vendor/rosell-dk/webp-convert/composer.json +8 -5
- vendor/rosell-dk/webp-convert/phpcs-ruleset.xml +8 -0
- vendor/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/LoggerTrait.php +1 -1
- vendor/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php +5 -4
- vendor/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php +6 -2
- vendor/rosell-dk/webp-convert/src/Convert/Converters/Gd.php +2 -2
- vendor/rosell-dk/webp-convert/src/Convert/Converters/ImageMagick.php +4 -3
- vendor/rosell-dk/webp-convert/src/Convert/Converters/Stack.php +0 -4
- vendor/rosell-dk/webp-convert/src/Convert/Converters/Vips.php +8 -8
- vendor/rosell-dk/webp-convert/src/Helpers/BinaryDiscovery.php +0 -109
- vendor/rosell-dk/webp-convert/src/Options/Option.php +1 -1
- vendor/rosell-dk/webp-convert/src/Serve/ServeConvertedWebP.php +9 -1
- webp-express.php +1 -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.25.
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
@@ -178,9 +178,6 @@ Bread on the table don't come for free, even though this plugin does, and always
|
|
178 |
* 30 Mar: Michael Schober
|
179 |
* 17 Mar: bluesix
|
180 |
* 13 Mar: Troglos
|
181 |
-
* 25 Feb: ItAdmin
|
182 |
-
* 31 Jan: MB
|
183 |
-
* 16 Dec: deepa
|
184 |
|
185 |
**Persons who contributed with extra generously amounts of coffee / lifetime backing (>30$) - thanks!:**
|
186 |
|
@@ -816,6 +813,11 @@ If you want to make sure that my coffee supplies don't run dry, you can even buy
|
|
816 |
|
817 |
== Changelog ==
|
818 |
|
|
|
|
|
|
|
|
|
|
|
819 |
= 0.25.4 =
|
820 |
(released 6 May 2022)
|
821 |
* AlterHTML (when using picture tags): Fixed charset problems for special characters in alt and title attributes. The bug was introduced in 0.25.2. Thanks to Cruglk for first pointing this out.
|
@@ -837,94 +839,13 @@ If you want to make sure that my coffee supplies don't run dry, you can even buy
|
|
837 |
* No exec()? - We don't give up easily, but now emulates it if possible, using proc_open(), passthru() or other alternatives. The result is that the cwebp converter now is available on more systems. Quality detection of jpegs also works on more systems now. The fallback feature with the emulations is btw implemented in a new library, [exec-with-fallback](https://github.com/rosell-dk/exec-with-fallback)
|
838 |
* Bugfix: Our WP CLI command "webp-express" has a quality option, but it was not working
|
839 |
|
840 |
-
= 0.24.2 =
|
841 |
-
*(released: 25 Nov 2021)*
|
842 |
-
* Bugfix: In FileManager, the original image wasn't showing on all systems
|
843 |
-
|
844 |
-
= 0.24.1 =
|
845 |
-
*(released: 24 Nov 2021)*
|
846 |
-
* Bugfix: On some systems, the converter test run that is done when showing the settings page could result in an uncatched error.
|
847 |
-
|
848 |
-
= 0.24.0 =
|
849 |
-
*(pre-released: 20 Nov 2021, not "released", in the sense that stable tag never pointed to this release)*
|
850 |
-
* Improved file manager: You can now tweak conversion settings, delete conversion and see mime type of images.
|
851 |
-
* Conversion logs are made more readable
|
852 |
-
* Bumped webp-convert to 0.24.0
|
853 |
-
|
854 |
-
For more info, see the closed issues on the [webp-express 0.24.0 milestone](https://github.com/rosell-dk/webp-express/milestone/45?closed=1)
|
855 |
-
|
856 |
-
= 0.23.0 =
|
857 |
-
*(pre-released: 15 Nov 2021)*
|
858 |
-
* Changed names for preventing replacing image with webp. Use "?dontreplace" / ".dontreplace" instead of "?original" and ".do-not-convert". The old ones are deprecated, but will still work (for a while)
|
859 |
-
* You can now convert images in the file manager and view conversion log
|
860 |
-
* The new file manager UI is now available in multisite too
|
861 |
-
* Changed names for the escape hatches that was introduced in 0.22. Use "?dontreplace" and ".dontreplace" rather than "?original" and ".do-not-convert". The old names still works
|
862 |
-
* Added message to users that have the Elementor plugin installed on how to configure Elementor to inline CSS in order for Alter HTML to be able to replace image URLs (only displayed when relevant)
|
863 |
-
* Added UI for "skip-these-precompiled-binaries" cwebp option. Thanks to @madmax4ever for posting code for this.
|
864 |
-
* Bumped dom-util-for-webp library to 0.5
|
865 |
-
* Bugfix: In multisite, Alter HTML produced wrong webp urls when destination structure was set to "image roots". Thanks to John A. Huebner II (@hube2) who lives on a big hill in central NY, USA for reporting the issue.
|
866 |
-
* Bugfix: One of the newly introduced escape hatches didn't work in Alter HTML.
|
867 |
-
|
868 |
-
For more info, see the closed issues on the [webp-express 0.23 milestone](https://github.com/rosell-dk/webp-express/milestone/43?closed=1)
|
869 |
-
|
870 |
-
= 0.22.1 =
|
871 |
-
*(released: 09 Nov 2021)*
|
872 |
-
* Bugfix: Old unupdated rewrite rules for redirecting to converter caused error (bug was introduced in 0.22.0). Thanks, @utrenkner for reacting quickly!
|
873 |
-
* 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.
|
874 |
-
|
875 |
-
= 0.22.0 =
|
876 |
-
*(released: 09 Nov 2021)*
|
877 |
-
* Added option to disable creating log files and button to do delete them. Thanks to Amit Sonkhiya and many others for suggesting this.
|
878 |
-
* WebP Express now prevents serving webps when they are bigger than the source. Added option for it (default is to prevent)
|
879 |
-
* You can now prevent that a certain image is redirected to webp by appending "?original" to the URL. Also works for Alter HTML.
|
880 |
-
* You can now prevent that a certain image is redirected to webp by placing a dummy ".do-not-convert" file next to the original.
|
881 |
-
* The conversion manager now uses the new "?original" escape hatch to avoid that the original image is being redirected. Beware that if you are on Nginx and have created rewrite rules, you will need to implement the same escape hatch to avoid the "Original" image to be redirected to webp. However, in a future update, I will probably implement a PHP script for serving the original so you can also just wait.
|
882 |
-
* Bugfix: Alter HTML could in some [rare cases](https://github.com/rosell-dk/webp-express/issues/528) produce invalid HTML.
|
883 |
-
For more info, see the closed issues on the [webp-express 0.22 milestone](https://github.com/rosell-dk/webp-express/milestone/13?closed=1)
|
884 |
-
* Bugfix: The "Enable redirection to converter" functionality was too greedy. It did not only redirect jpegs and pngs, but any file request. The bug occurred when Destination folder was set to "Image roots". The fix updates the .htaccess files if neccessary.
|
885 |
-
* Minor bugfix: Symlinking the webp-express plugin folder would break "Redirection to converter" functionality
|
886 |
-
|
887 |
-
For more info, see the closed issues on the [webp-express 0.22 milestone](https://github.com/rosell-dk/webp-express/milestone/13?closed=1)
|
888 |
-
|
889 |
-
= 0.21.1 =
|
890 |
-
*(released: 27 Oct 2021)*
|
891 |
-
* Bugfix: File manager could not handle many images. It now loads tree branches on need basis instead of the complete tree in one go
|
892 |
-
* Bugfix: For mulisite, the redirect after settings save was not working (bug introduced in 0.21.0)
|
893 |
-
|
894 |
-
For more info, see the closed issues on the [webp-express 0.21.1 milestone](https://github.com/rosell-dk/webp-express/milestone/42?closed=1)
|
895 |
-
|
896 |
-
= 0.21.0 =
|
897 |
-
*(released: 25 Oct 2021)*
|
898 |
-
* Added image browser (in Media tab)
|
899 |
-
* Updated webp convert library to 2.7.0.
|
900 |
-
* ImageMagick now supports the "near-lossless" option (provided Imagick >= 7.0.10-54)
|
901 |
-
* Added "try-common-system-paths" option for ImageMagick (default: true). Thanks to Henrik Alves for adding this option.
|
902 |
-
* Bugfix: Handling Uncaught Fatal Exception during .htaccess read failure. Thanks to Manuel D'Orso from Italy for the fix.
|
903 |
-
* Bugfix: File names which were not UTF8 caused trouble in the Bulk Convert. Thank to "mills4078" for the fix
|
904 |
-
* Bugfix: Redirection back to settings after saving settings failed on some systems. Thanks to Martin Rehberger (@kingkero) from Germany for the fix.
|
905 |
-
* Bugfix: Webp urls did not contain port number (only relevant when the website was not on default port number). Thanks to Nicolas LIENART (@nicolnt) from France for providing the fix.
|
906 |
-
|
907 |
-
For more info, see the closed issues on the [webp-express 0.21.0 milestone](https://github.com/rosell-dk/webp-express/milestone/41?closed=1) and the
|
908 |
-
[webp-convert 2.7.0 milestone](https://github.com/rosell-dk/webp-convert/milestone/24?closed=1)
|
909 |
-
|
910 |
-
= 0.20.1 =
|
911 |
-
*(released: 20 Jun 2021)*
|
912 |
-
* Bugfix: Removed composer.lock. It was locked on PHP 7.2, which caused server error on some sites (only some sites with old php were affected). Also deleted the library which required PHP 7.2 (onnov/detect-encoding/). The functionality is not really needed.
|
913 |
-
|
914 |
-
= 0.20.0 =
|
915 |
-
*(released: 17 Jun 2021)*
|
916 |
-
* Added WP CLI support. Add "wp webp-express convert" to crontab for nightly conversions of new images! Thanks to Isuru Sampath Ratnayake from Sri Lanka for initializing this.
|
917 |
-
* Added "sharp-yuv" (not as option, but as always on). Better YUV->RGB color conversion at almost no price. [Read more here](https://www.ctrl.blog/entry/webp-sharp-yuv.html). Supported by cwebp, vips, gmagick, graphicsmagick, imagick and imagemagick
|
918 |
-
* Bumped cwebp binaries to 1.2.0
|
919 |
-
* cwebp now only validates hash of supplied precompiled binaries when necessary. This cuts down conversion time.
|
920 |
-
* Convert on upload now defaults to false, as it may impact upload experience in themes with many formats.
|
921 |
-
|
922 |
-
For more info, see the closed issues on the [0.20.0 milestone on the github repository](https://github.com/rosell-dk/webp-express/milestone/38?closed=1)
|
923 |
-
|
924 |
For older releases, check out changelog.txt
|
925 |
|
926 |
== Upgrade Notice ==
|
927 |
|
|
|
|
|
|
|
928 |
= 0.25.4 =
|
929 |
* AlterHTML (when using picture tags): Fixed charset problems for special characters in alt and title attributes.
|
930 |
|
4 |
Tags: webp, images, performance
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 5.8
|
7 |
+
Stable tag: 0.25.5
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
178 |
* 30 Mar: Michael Schober
|
179 |
* 17 Mar: bluesix
|
180 |
* 13 Mar: Troglos
|
|
|
|
|
|
|
181 |
|
182 |
**Persons who contributed with extra generously amounts of coffee / lifetime backing (>30$) - thanks!:**
|
183 |
|
813 |
|
814 |
== Changelog ==
|
815 |
|
816 |
+
= 0.25.5 =
|
817 |
+
(released 23 May 2022)
|
818 |
+
* When using the "Prevent using webps larger than original" with Alter HTML (picture tags) on images with srcset, those webps that where larger than the originals was picked out from the srcset for the webp. This could lead to bad quality images. In the fix, the image will only have a webp source alternative when ALL the webps are smaller than their originals (when the "prevent..." option is set).
|
819 |
+
* Bugfix: In rare cases, WebP Express could fail detecting mime type
|
820 |
+
|
821 |
= 0.25.4 =
|
822 |
(released 6 May 2022)
|
823 |
* AlterHTML (when using picture tags): Fixed charset problems for special characters in alt and title attributes. The bug was introduced in 0.25.2. Thanks to Cruglk for first pointing this out.
|
839 |
* No exec()? - We don't give up easily, but now emulates it if possible, using proc_open(), passthru() or other alternatives. The result is that the cwebp converter now is available on more systems. Quality detection of jpegs also works on more systems now. The fallback feature with the emulations is btw implemented in a new library, [exec-with-fallback](https://github.com/rosell-dk/exec-with-fallback)
|
840 |
* Bugfix: Our WP CLI command "webp-express" has a quality option, but it was not working
|
841 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
842 |
For older releases, check out changelog.txt
|
843 |
|
844 |
== Upgrade Notice ==
|
845 |
|
846 |
+
= 0.25.5 =
|
847 |
+
* Two bugfixes, one of them in Alter HTML. If you are using Alter HTML with picture tags and have enabled "Prevent using webps larger than original" and are using page caching, you should flush your page cache.
|
848 |
+
|
849 |
= 0.25.4 =
|
850 |
* AlterHTML (when using picture tags): Fixed charset problems for special characters in alt and title attributes.
|
851 |
|
changelog.txt
CHANGED
@@ -1,4 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 0.25.4 =
|
|
|
2 |
* AlterHTML (when using picture tags): Fixed charset problems for special characters in alt and title attributes. The bug was introduced in 0.25.2. Thanks to Cruglk for first pointing this out.
|
3 |
|
4 |
= 0.25.3 =
|
1 |
+
= 0.25.5 =
|
2 |
+
(released 23 May 2022)
|
3 |
+
* When using the "Prevent using webps larger than original" with Alter HTML (picture tags) on images with srcset, those webps that where larger than the originals was picked out from the srcset for the webp. This could lead to bad quality images. In the fix, the image will only have a webp source alternative when ALL the webps are smaller than their originals (when the "prevent..." option is set). Note: If you were affected by this and use a page caching plugin, you should flush your page cache!
|
4 |
+
* Bugfix: In rare cases, WebP Express could fail detecting mime type
|
5 |
+
|
6 |
= 0.25.4 =
|
7 |
+
(released 6 May 2022)
|
8 |
* AlterHTML (when using picture tags): Fixed charset problems for special characters in alt and title attributes. The bug was introduced in 0.25.2. Thanks to Cruglk for first pointing this out.
|
9 |
|
10 |
= 0.25.3 =
|
composer.json
CHANGED
@@ -5,11 +5,11 @@
|
|
5 |
"license": "MIT",
|
6 |
"require": {
|
7 |
"composer/installers": "^1.12.0",
|
8 |
-
"rosell-dk/webp-convert": "^2.9.
|
9 |
"rosell-dk/webp-convert-cloud-service": "^2.0.0",
|
10 |
"rosell-dk/dom-util-for-webp": "^0.6.3",
|
11 |
"rosell-dk/htaccess-capability-tester": "^0.9.0",
|
12 |
-
"rosell-dk/image-mime-type-guesser": "^
|
13 |
},
|
14 |
"require-dev": {
|
15 |
},
|
5 |
"license": "MIT",
|
6 |
"require": {
|
7 |
"composer/installers": "^1.12.0",
|
8 |
+
"rosell-dk/webp-convert": "^2.9.1",
|
9 |
"rosell-dk/webp-convert-cloud-service": "^2.0.0",
|
10 |
"rosell-dk/dom-util-for-webp": "^0.6.3",
|
11 |
"rosell-dk/htaccess-capability-tester": "^0.9.0",
|
12 |
+
"rosell-dk/image-mime-type-guesser": "^1.1.1"
|
13 |
},
|
14 |
"require-dev": {
|
15 |
},
|
docs/publishing.md
CHANGED
@@ -116,12 +116,12 @@ svn status | grep '^!' | awk '{print $2}' | xargs svn delete --force (t
|
|
116 |
Then add a new tag
|
117 |
```
|
118 |
cd svn
|
119 |
-
svn cp trunk tags/0.25.
|
120 |
```
|
121 |
|
122 |
And commit!
|
123 |
```
|
124 |
-
svn ci -m '0.25.
|
125 |
```
|
126 |
|
127 |
|
116 |
Then add a new tag
|
117 |
```
|
118 |
cd svn
|
119 |
+
svn cp trunk tags/0.25.4 (this will copy trunk into a new tag)
|
120 |
```
|
121 |
|
122 |
And commit!
|
123 |
```
|
124 |
+
svn ci -m '0.25.4'
|
125 |
```
|
126 |
|
127 |
|
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.25.
|
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.25.5. ' . $msgTop . ', ' . date("Y-m-d H:i:s") . "\n\r\n\r" . $text;
|
575 |
|
576 |
$logFile = self::getLogFilename($source, $logDir);
|
577 |
|
lib/classes/WebPOnDemand.php
CHANGED
@@ -201,6 +201,8 @@ class WebPOnDemand extends WodConfigLoader
|
|
201 |
|
202 |
// Done with sanitizing, lets get to work!
|
203 |
// ---------------------------------------
|
|
|
|
|
204 |
if (isset($wodOptions['success-response']) && ($wodOptions['success-response'] == 'original')) {
|
205 |
$serveOptions['serve-original'] = true;
|
206 |
$serveOptions['serve-image']['headers']['vary-accept'] = false;
|
@@ -273,7 +275,11 @@ class WebPOnDemand extends WodConfigLoader
|
|
273 |
} catch (ValidateException $e) {
|
274 |
self::exitWithError('Validation failed for ' . self::$checking . ': '. $e->getMessage());
|
275 |
} catch (\Exception $e) {
|
276 |
-
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
}
|
279 |
}
|
201 |
|
202 |
// Done with sanitizing, lets get to work!
|
203 |
// ---------------------------------------
|
204 |
+
self::$checking = 'done';
|
205 |
+
|
206 |
if (isset($wodOptions['success-response']) && ($wodOptions['success-response'] == 'original')) {
|
207 |
$serveOptions['serve-original'] = true;
|
208 |
$serveOptions['serve-image']['headers']['vary-accept'] = false;
|
275 |
} catch (ValidateException $e) {
|
276 |
self::exitWithError('Validation failed for ' . self::$checking . ': '. $e->getMessage());
|
277 |
} catch (\Exception $e) {
|
278 |
+
if (self::$checking == 'done') {
|
279 |
+
self::exitWithError('Error occured during conversion/serving:' . $e->getMessage());
|
280 |
+
} else {
|
281 |
+
self::exitWithError('Error occured while calculating ' . self::$checking . ': '. $e->getMessage());
|
282 |
+
}
|
283 |
}
|
284 |
}
|
285 |
}
|
lib/options/options/general/prevent-using-webps-larger-than-original.inc
CHANGED
@@ -6,7 +6,15 @@
|
|
6 |
'If you are motivated by limiting bandwidth usage and having a fast website, keep this option enabled. ' .
|
7 |
'If you are more concerned about SEO and a penalty for serving jpegs and pngs rather than webps, disable it.' .
|
8 |
'</p>' .
|
9 |
-
'<p>The option is used both when generating .htaccess rules and in Alter HTML.</p>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
);
|
11 |
?></th>
|
12 |
<td>
|
6 |
'If you are motivated by limiting bandwidth usage and having a fast website, keep this option enabled. ' .
|
7 |
'If you are more concerned about SEO and a penalty for serving jpegs and pngs rather than webps, disable it.' .
|
8 |
'</p>' .
|
9 |
+
'<p>The option is used both when generating .htaccess rules and in Alter HTML.</p>' .
|
10 |
+
'<p>Note: If you are using Alter HTML with picture tags and have images with a srcset ' .
|
11 |
+
'attribute, WebP Express generates a source element with type set to "image/webp". This source ' .
|
12 |
+
'thus points to a bundle of webp images. From 0.25.5 and forward, when this option is enabled, ' .
|
13 |
+
'WebP Express will only add the source element when ALL those webp images are smaller than their originals. ' .
|
14 |
+
'In such a situation (using Alter HTML with picture tags), it might be a better strategy to disable this option. ' .
|
15 |
+
'Especially if your images generally have the srcset attribute set. Chances are that only a few of the webps in ' .
|
16 |
+
'the source set are bigger than the corresponding originals, and chances are that they are only slightly bigger.' .
|
17 |
+
'</p>'
|
18 |
);
|
19 |
?></th>
|
20 |
<td>
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -118,6 +118,9 @@ return array(
|
|
118 |
'ExecWithFallback\\Passthru' => $vendorDir . '/rosell-dk/exec-with-fallback/src/Passthru.php',
|
119 |
'ExecWithFallback\\ProcOpen' => $vendorDir . '/rosell-dk/exec-with-fallback/src/ProcOpen.php',
|
120 |
'ExecWithFallback\\ShellExec' => $vendorDir . '/rosell-dk/exec-with-fallback/src/ShellExec.php',
|
|
|
|
|
|
|
121 |
'HtaccessCapabilityTester\\HtaccessCapabilityTester' => $vendorDir . '/rosell-dk/htaccess-capability-tester/src/HtaccessCapabilityTester.php',
|
122 |
'HtaccessCapabilityTester\\HttpRequesterInterface' => $vendorDir . '/rosell-dk/htaccess-capability-tester/src/HttpRequesterInterface.php',
|
123 |
'HtaccessCapabilityTester\\HttpResponse' => $vendorDir . '/rosell-dk/htaccess-capability-tester/src/HttpResponse.php',
|
@@ -147,11 +150,14 @@ return array(
|
|
147 |
'ImageMimeTypeGuesser\\Detectors\\FInfo' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/FInfo.php',
|
148 |
'ImageMimeTypeGuesser\\Detectors\\GetImageSize' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/GetImageSize.php',
|
149 |
'ImageMimeTypeGuesser\\Detectors\\MimeContentType' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/MimeContentType.php',
|
150 |
-
'ImageMimeTypeGuesser\\Detectors\\
|
151 |
'ImageMimeTypeGuesser\\Detectors\\Stack' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php',
|
152 |
'ImageMimeTypeGuesser\\GuessFromExtension' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php',
|
153 |
'ImageMimeTypeGuesser\\ImageMimeTypeGuesser' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/ImageMimeTypeGuesser.php',
|
|
|
|
|
154 |
'KubAT\\PhpSimple\\HtmlDomParser' => $vendorDir . '/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/HtmlDomParser.php',
|
|
|
155 |
'WebPConvertCloudService\\AccessCheck' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/AccessCheck.php',
|
156 |
'WebPConvertCloudService\\Serve' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/Serve.php',
|
157 |
'WebPConvertCloudService\\WebPConvertCloudService' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/WebPConvertCloudService.php',
|
@@ -197,8 +203,6 @@ return array(
|
|
197 |
'WebPConvert\\Exceptions\\InvalidInput\\InvalidImageTypeException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/InvalidImageTypeException.php',
|
198 |
'WebPConvert\\Exceptions\\InvalidInput\\TargetNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/TargetNotFoundException.php',
|
199 |
'WebPConvert\\Exceptions\\WebPConvertException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
|
200 |
-
'WebPConvert\\Helpers\\BinaryDiscovery' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/BinaryDiscovery.php',
|
201 |
-
'WebPConvert\\Helpers\\FileExists' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/FileExists.php',
|
202 |
'WebPConvert\\Helpers\\InputValidator' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/InputValidator.php',
|
203 |
'WebPConvert\\Helpers\\MimeType' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/MimeType.php',
|
204 |
'WebPConvert\\Helpers\\PathChecker' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/PathChecker.php',
|
118 |
'ExecWithFallback\\Passthru' => $vendorDir . '/rosell-dk/exec-with-fallback/src/Passthru.php',
|
119 |
'ExecWithFallback\\ProcOpen' => $vendorDir . '/rosell-dk/exec-with-fallback/src/ProcOpen.php',
|
120 |
'ExecWithFallback\\ShellExec' => $vendorDir . '/rosell-dk/exec-with-fallback/src/ShellExec.php',
|
121 |
+
'FileUtil\\FileExists' => $vendorDir . '/rosell-dk/file-util/src/FileExists.php',
|
122 |
+
'FileUtil\\FileExistsUsingExec' => $vendorDir . '/rosell-dk/file-util/src/FileExistsUsingExec.php',
|
123 |
+
'FileUtil\\PathValidator' => $vendorDir . '/rosell-dk/file-util/src/PathValidator.php',
|
124 |
'HtaccessCapabilityTester\\HtaccessCapabilityTester' => $vendorDir . '/rosell-dk/htaccess-capability-tester/src/HtaccessCapabilityTester.php',
|
125 |
'HtaccessCapabilityTester\\HttpRequesterInterface' => $vendorDir . '/rosell-dk/htaccess-capability-tester/src/HttpRequesterInterface.php',
|
126 |
'HtaccessCapabilityTester\\HttpResponse' => $vendorDir . '/rosell-dk/htaccess-capability-tester/src/HttpResponse.php',
|
150 |
'ImageMimeTypeGuesser\\Detectors\\FInfo' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/FInfo.php',
|
151 |
'ImageMimeTypeGuesser\\Detectors\\GetImageSize' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/GetImageSize.php',
|
152 |
'ImageMimeTypeGuesser\\Detectors\\MimeContentType' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/MimeContentType.php',
|
153 |
+
'ImageMimeTypeGuesser\\Detectors\\SignatureSniffer' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/SignatureSniffer.php',
|
154 |
'ImageMimeTypeGuesser\\Detectors\\Stack' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php',
|
155 |
'ImageMimeTypeGuesser\\GuessFromExtension' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php',
|
156 |
'ImageMimeTypeGuesser\\ImageMimeTypeGuesser' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/ImageMimeTypeGuesser.php',
|
157 |
+
'ImageMimeTypeGuesser\\MimeMap' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/MimeMap.php',
|
158 |
+
'ImageMimeTypeSniffer\\ImageMimeTypeSniffer' => $vendorDir . '/rosell-dk/image-mime-type-sniffer/src/ImageMimeTypeSniffer.php',
|
159 |
'KubAT\\PhpSimple\\HtmlDomParser' => $vendorDir . '/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/HtmlDomParser.php',
|
160 |
+
'LocateBinaries\\LocateBinaries' => $vendorDir . '/rosell-dk/locate-binaries/src/LocateBinaries.php',
|
161 |
'WebPConvertCloudService\\AccessCheck' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/AccessCheck.php',
|
162 |
'WebPConvertCloudService\\Serve' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/Serve.php',
|
163 |
'WebPConvertCloudService\\WebPConvertCloudService' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/WebPConvertCloudService.php',
|
203 |
'WebPConvert\\Exceptions\\InvalidInput\\InvalidImageTypeException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/InvalidImageTypeException.php',
|
204 |
'WebPConvert\\Exceptions\\InvalidInput\\TargetNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/TargetNotFoundException.php',
|
205 |
'WebPConvert\\Exceptions\\WebPConvertException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
|
|
|
|
|
206 |
'WebPConvert\\Helpers\\InputValidator' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/InputValidator.php',
|
207 |
'WebPConvert\\Helpers\\MimeType' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/MimeType.php',
|
208 |
'WebPConvert\\Helpers\\PathChecker' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/PathChecker.php',
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -8,8 +8,11 @@ $baseDir = dirname($vendorDir);
|
|
8 |
return array(
|
9 |
'WebPConvert\\' => array($vendorDir . '/rosell-dk/webp-convert/src'),
|
10 |
'WebPConvertCloudService\\' => array($vendorDir . '/rosell-dk/webp-convert-cloud-service/src'),
|
|
|
|
|
11 |
'ImageMimeTypeGuesser\\' => array($vendorDir . '/rosell-dk/image-mime-type-guesser/src'),
|
12 |
'HtaccessCapabilityTester\\' => array($vendorDir . '/rosell-dk/htaccess-capability-tester/src'),
|
|
|
13 |
'ExecWithFallback\\' => array($vendorDir . '/rosell-dk/exec-with-fallback/src'),
|
14 |
'DOMUtilForWebP\\' => array($vendorDir . '/rosell-dk/dom-util-for-webp/src'),
|
15 |
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'),
|
8 |
return array(
|
9 |
'WebPConvert\\' => array($vendorDir . '/rosell-dk/webp-convert/src'),
|
10 |
'WebPConvertCloudService\\' => array($vendorDir . '/rosell-dk/webp-convert-cloud-service/src'),
|
11 |
+
'LocateBinaries\\' => array($vendorDir . '/rosell-dk/locate-binaries/src'),
|
12 |
+
'ImageMimeTypeSniffer\\' => array($vendorDir . '/rosell-dk/image-mime-type-sniffer/src'),
|
13 |
'ImageMimeTypeGuesser\\' => array($vendorDir . '/rosell-dk/image-mime-type-guesser/src'),
|
14 |
'HtaccessCapabilityTester\\' => array($vendorDir . '/rosell-dk/htaccess-capability-tester/src'),
|
15 |
+
'FileUtil\\' => array($vendorDir . '/rosell-dk/file-util/src'),
|
16 |
'ExecWithFallback\\' => array($vendorDir . '/rosell-dk/exec-with-fallback/src'),
|
17 |
'DOMUtilForWebP\\' => array($vendorDir . '/rosell-dk/dom-util-for-webp/src'),
|
18 |
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'),
|
vendor/composer/autoload_static.php
CHANGED
@@ -12,14 +12,23 @@ class ComposerStaticInit16597e36dd1bfcd787ed5a8e6d908243
|
|
12 |
'WebPConvert\\' => 12,
|
13 |
'WebPConvertCloudService\\' => 24,
|
14 |
),
|
|
|
|
|
|
|
|
|
15 |
'I' =>
|
16 |
array (
|
|
|
17 |
'ImageMimeTypeGuesser\\' => 21,
|
18 |
),
|
19 |
'H' =>
|
20 |
array (
|
21 |
'HtaccessCapabilityTester\\' => 25,
|
22 |
),
|
|
|
|
|
|
|
|
|
23 |
'E' =>
|
24 |
array (
|
25 |
'ExecWithFallback\\' => 17,
|
@@ -43,6 +52,14 @@ class ComposerStaticInit16597e36dd1bfcd787ed5a8e6d908243
|
|
43 |
array (
|
44 |
0 => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src',
|
45 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
'ImageMimeTypeGuesser\\' =>
|
47 |
array (
|
48 |
0 => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src',
|
@@ -51,6 +68,10 @@ class ComposerStaticInit16597e36dd1bfcd787ed5a8e6d908243
|
|
51 |
array (
|
52 |
0 => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src',
|
53 |
),
|
|
|
|
|
|
|
|
|
54 |
'ExecWithFallback\\' =>
|
55 |
array (
|
56 |
0 => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src',
|
@@ -188,6 +209,9 @@ class ComposerStaticInit16597e36dd1bfcd787ed5a8e6d908243
|
|
188 |
'ExecWithFallback\\Passthru' => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src/Passthru.php',
|
189 |
'ExecWithFallback\\ProcOpen' => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src/ProcOpen.php',
|
190 |
'ExecWithFallback\\ShellExec' => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src/ShellExec.php',
|
|
|
|
|
|
|
191 |
'HtaccessCapabilityTester\\HtaccessCapabilityTester' => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src/HtaccessCapabilityTester.php',
|
192 |
'HtaccessCapabilityTester\\HttpRequesterInterface' => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src/HttpRequesterInterface.php',
|
193 |
'HtaccessCapabilityTester\\HttpResponse' => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src/HttpResponse.php',
|
@@ -217,11 +241,14 @@ class ComposerStaticInit16597e36dd1bfcd787ed5a8e6d908243
|
|
217 |
'ImageMimeTypeGuesser\\Detectors\\FInfo' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/FInfo.php',
|
218 |
'ImageMimeTypeGuesser\\Detectors\\GetImageSize' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/GetImageSize.php',
|
219 |
'ImageMimeTypeGuesser\\Detectors\\MimeContentType' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/MimeContentType.php',
|
220 |
-
'ImageMimeTypeGuesser\\Detectors\\
|
221 |
'ImageMimeTypeGuesser\\Detectors\\Stack' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php',
|
222 |
'ImageMimeTypeGuesser\\GuessFromExtension' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php',
|
223 |
'ImageMimeTypeGuesser\\ImageMimeTypeGuesser' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/ImageMimeTypeGuesser.php',
|
|
|
|
|
224 |
'KubAT\\PhpSimple\\HtmlDomParser' => __DIR__ . '/..' . '/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/HtmlDomParser.php',
|
|
|
225 |
'WebPConvertCloudService\\AccessCheck' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/AccessCheck.php',
|
226 |
'WebPConvertCloudService\\Serve' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/Serve.php',
|
227 |
'WebPConvertCloudService\\WebPConvertCloudService' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/WebPConvertCloudService.php',
|
@@ -267,8 +294,6 @@ class ComposerStaticInit16597e36dd1bfcd787ed5a8e6d908243
|
|
267 |
'WebPConvert\\Exceptions\\InvalidInput\\InvalidImageTypeException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/InvalidImageTypeException.php',
|
268 |
'WebPConvert\\Exceptions\\InvalidInput\\TargetNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/TargetNotFoundException.php',
|
269 |
'WebPConvert\\Exceptions\\WebPConvertException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
|
270 |
-
'WebPConvert\\Helpers\\BinaryDiscovery' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/BinaryDiscovery.php',
|
271 |
-
'WebPConvert\\Helpers\\FileExists' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/FileExists.php',
|
272 |
'WebPConvert\\Helpers\\InputValidator' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/InputValidator.php',
|
273 |
'WebPConvert\\Helpers\\MimeType' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/MimeType.php',
|
274 |
'WebPConvert\\Helpers\\PathChecker' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/PathChecker.php',
|
12 |
'WebPConvert\\' => 12,
|
13 |
'WebPConvertCloudService\\' => 24,
|
14 |
),
|
15 |
+
'L' =>
|
16 |
+
array (
|
17 |
+
'LocateBinaries\\' => 15,
|
18 |
+
),
|
19 |
'I' =>
|
20 |
array (
|
21 |
+
'ImageMimeTypeSniffer\\' => 21,
|
22 |
'ImageMimeTypeGuesser\\' => 21,
|
23 |
),
|
24 |
'H' =>
|
25 |
array (
|
26 |
'HtaccessCapabilityTester\\' => 25,
|
27 |
),
|
28 |
+
'F' =>
|
29 |
+
array (
|
30 |
+
'FileUtil\\' => 9,
|
31 |
+
),
|
32 |
'E' =>
|
33 |
array (
|
34 |
'ExecWithFallback\\' => 17,
|
52 |
array (
|
53 |
0 => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src',
|
54 |
),
|
55 |
+
'LocateBinaries\\' =>
|
56 |
+
array (
|
57 |
+
0 => __DIR__ . '/..' . '/rosell-dk/locate-binaries/src',
|
58 |
+
),
|
59 |
+
'ImageMimeTypeSniffer\\' =>
|
60 |
+
array (
|
61 |
+
0 => __DIR__ . '/..' . '/rosell-dk/image-mime-type-sniffer/src',
|
62 |
+
),
|
63 |
'ImageMimeTypeGuesser\\' =>
|
64 |
array (
|
65 |
0 => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src',
|
68 |
array (
|
69 |
0 => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src',
|
70 |
),
|
71 |
+
'FileUtil\\' =>
|
72 |
+
array (
|
73 |
+
0 => __DIR__ . '/..' . '/rosell-dk/file-util/src',
|
74 |
+
),
|
75 |
'ExecWithFallback\\' =>
|
76 |
array (
|
77 |
0 => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src',
|
209 |
'ExecWithFallback\\Passthru' => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src/Passthru.php',
|
210 |
'ExecWithFallback\\ProcOpen' => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src/ProcOpen.php',
|
211 |
'ExecWithFallback\\ShellExec' => __DIR__ . '/..' . '/rosell-dk/exec-with-fallback/src/ShellExec.php',
|
212 |
+
'FileUtil\\FileExists' => __DIR__ . '/..' . '/rosell-dk/file-util/src/FileExists.php',
|
213 |
+
'FileUtil\\FileExistsUsingExec' => __DIR__ . '/..' . '/rosell-dk/file-util/src/FileExistsUsingExec.php',
|
214 |
+
'FileUtil\\PathValidator' => __DIR__ . '/..' . '/rosell-dk/file-util/src/PathValidator.php',
|
215 |
'HtaccessCapabilityTester\\HtaccessCapabilityTester' => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src/HtaccessCapabilityTester.php',
|
216 |
'HtaccessCapabilityTester\\HttpRequesterInterface' => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src/HttpRequesterInterface.php',
|
217 |
'HtaccessCapabilityTester\\HttpResponse' => __DIR__ . '/..' . '/rosell-dk/htaccess-capability-tester/src/HttpResponse.php',
|
241 |
'ImageMimeTypeGuesser\\Detectors\\FInfo' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/FInfo.php',
|
242 |
'ImageMimeTypeGuesser\\Detectors\\GetImageSize' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/GetImageSize.php',
|
243 |
'ImageMimeTypeGuesser\\Detectors\\MimeContentType' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/MimeContentType.php',
|
244 |
+
'ImageMimeTypeGuesser\\Detectors\\SignatureSniffer' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/SignatureSniffer.php',
|
245 |
'ImageMimeTypeGuesser\\Detectors\\Stack' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php',
|
246 |
'ImageMimeTypeGuesser\\GuessFromExtension' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php',
|
247 |
'ImageMimeTypeGuesser\\ImageMimeTypeGuesser' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/ImageMimeTypeGuesser.php',
|
248 |
+
'ImageMimeTypeGuesser\\MimeMap' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/MimeMap.php',
|
249 |
+
'ImageMimeTypeSniffer\\ImageMimeTypeSniffer' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-sniffer/src/ImageMimeTypeSniffer.php',
|
250 |
'KubAT\\PhpSimple\\HtmlDomParser' => __DIR__ . '/..' . '/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/HtmlDomParser.php',
|
251 |
+
'LocateBinaries\\LocateBinaries' => __DIR__ . '/..' . '/rosell-dk/locate-binaries/src/LocateBinaries.php',
|
252 |
'WebPConvertCloudService\\AccessCheck' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/AccessCheck.php',
|
253 |
'WebPConvertCloudService\\Serve' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/Serve.php',
|
254 |
'WebPConvertCloudService\\WebPConvertCloudService' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/WebPConvertCloudService.php',
|
294 |
'WebPConvert\\Exceptions\\InvalidInput\\InvalidImageTypeException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/InvalidImageTypeException.php',
|
295 |
'WebPConvert\\Exceptions\\InvalidInput\\TargetNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/TargetNotFoundException.php',
|
296 |
'WebPConvert\\Exceptions\\WebPConvertException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
|
|
|
|
|
297 |
'WebPConvert\\Helpers\\InputValidator' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/InputValidator.php',
|
298 |
'WebPConvert\\Helpers\\MimeType' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/MimeType.php',
|
299 |
'WebPConvert\\Helpers\\PathChecker' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/PathChecker.php',
|
vendor/composer/installed.json
CHANGED
@@ -363,6 +363,83 @@
|
|
363 |
],
|
364 |
"install-path": "../rosell-dk/exec-with-fallback"
|
365 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
{
|
367 |
"name": "rosell-dk/htaccess-capability-tester",
|
368 |
"version": "0.9.1",
|
@@ -441,25 +518,30 @@
|
|
441 |
},
|
442 |
{
|
443 |
"name": "rosell-dk/image-mime-type-guesser",
|
444 |
-
"version": "
|
445 |
-
"version_normalized": "
|
446 |
"source": {
|
447 |
"type": "git",
|
448 |
"url": "https://github.com/rosell-dk/image-mime-type-guesser.git",
|
449 |
-
"reference": "
|
450 |
},
|
451 |
"dist": {
|
452 |
"type": "zip",
|
453 |
-
"url": "https://api.github.com/repos/rosell-dk/image-mime-type-guesser/zipball/
|
454 |
-
"reference": "
|
455 |
"shasum": ""
|
456 |
},
|
|
|
|
|
|
|
|
|
457 |
"require-dev": {
|
458 |
"friendsofphp/php-cs-fixer": "^2.11",
|
|
|
459 |
"phpunit/phpunit": "^9.3",
|
460 |
"squizlabs/php_codesniffer": "3.*"
|
461 |
},
|
462 |
-
"time": "
|
463 |
"type": "library",
|
464 |
"extra": {
|
465 |
"scripts-descriptions": {
|
@@ -497,7 +579,7 @@
|
|
497 |
],
|
498 |
"support": {
|
499 |
"issues": "https://github.com/rosell-dk/image-mime-type-guesser/issues",
|
500 |
-
"source": "https://github.com/rosell-dk/image-mime-type-guesser/tree/
|
501 |
},
|
502 |
"funding": [
|
503 |
{
|
@@ -511,28 +593,186 @@
|
|
511 |
],
|
512 |
"install-path": "../rosell-dk/image-mime-type-guesser"
|
513 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
{
|
515 |
"name": "rosell-dk/webp-convert",
|
516 |
-
"version": "2.9.
|
517 |
-
"version_normalized": "2.9.
|
518 |
"source": {
|
519 |
"type": "git",
|
520 |
"url": "https://github.com/rosell-dk/webp-convert.git",
|
521 |
-
"reference": "
|
522 |
},
|
523 |
"dist": {
|
524 |
"type": "zip",
|
525 |
-
"url": "https://api.github.com/repos/rosell-dk/webp-convert/zipball/
|
526 |
-
"reference": "
|
527 |
"shasum": ""
|
528 |
},
|
529 |
"require": {
|
530 |
"php": "^5.6 | ^7.0 | ^8.0",
|
531 |
"rosell-dk/exec-with-fallback": "^1.0.0",
|
532 |
-
"rosell-dk/image-mime-type-guesser": "^
|
|
|
533 |
},
|
534 |
"require-dev": {
|
535 |
"friendsofphp/php-cs-fixer": "^2.11",
|
|
|
536 |
"phpunit/phpunit": "^9.3",
|
537 |
"squizlabs/php_codesniffer": "3.*"
|
538 |
},
|
@@ -542,7 +782,7 @@
|
|
542 |
"ext-vips": "to use Vips extension for converting.",
|
543 |
"php-stan/php-stan": "Suggested for dev, in order to analyse code before committing"
|
544 |
},
|
545 |
-
"time": "
|
546 |
"type": "library",
|
547 |
"extra": {
|
548 |
"scripts-descriptions": {
|
@@ -591,7 +831,7 @@
|
|
591 |
],
|
592 |
"support": {
|
593 |
"issues": "https://github.com/rosell-dk/webp-convert/issues",
|
594 |
-
"source": "https://github.com/rosell-dk/webp-convert/tree/2.9.
|
595 |
},
|
596 |
"funding": [
|
597 |
{
|
363 |
],
|
364 |
"install-path": "../rosell-dk/exec-with-fallback"
|
365 |
},
|
366 |
+
{
|
367 |
+
"name": "rosell-dk/file-util",
|
368 |
+
"version": "0.1.1",
|
369 |
+
"version_normalized": "0.1.1.0",
|
370 |
+
"source": {
|
371 |
+
"type": "git",
|
372 |
+
"url": "https://github.com/rosell-dk/file-util.git",
|
373 |
+
"reference": "2ff895308c37f448b34b031cfbfd8e45f43936fd"
|
374 |
+
},
|
375 |
+
"dist": {
|
376 |
+
"type": "zip",
|
377 |
+
"url": "https://api.github.com/repos/rosell-dk/file-util/zipball/2ff895308c37f448b34b031cfbfd8e45f43936fd",
|
378 |
+
"reference": "2ff895308c37f448b34b031cfbfd8e45f43936fd",
|
379 |
+
"shasum": ""
|
380 |
+
},
|
381 |
+
"require": {
|
382 |
+
"php": ">=5.4",
|
383 |
+
"rosell-dk/exec-with-fallback": "^1.0.0"
|
384 |
+
},
|
385 |
+
"require-dev": {
|
386 |
+
"friendsofphp/php-cs-fixer": "^2.11",
|
387 |
+
"mikey179/vfsstream": "^1.6",
|
388 |
+
"phpstan/phpstan": "^1.5",
|
389 |
+
"phpunit/phpunit": "^9.3",
|
390 |
+
"squizlabs/php_codesniffer": "3.*"
|
391 |
+
},
|
392 |
+
"time": "2022-04-19T10:12:31+00:00",
|
393 |
+
"type": "library",
|
394 |
+
"extra": {
|
395 |
+
"scripts-descriptions": {
|
396 |
+
"ci": "Run tests before CI",
|
397 |
+
"phpcs": "Checks coding styles (PSR2) of file/dir, which you must supply. To check all, supply 'src'",
|
398 |
+
"phpcbf": "Fix coding styles (PSR2) of file/dir, which you must supply. To fix all, supply 'src'",
|
399 |
+
"cs-fix-all": "Fix the coding style of all the source files, to comply with the PSR-2 coding standard",
|
400 |
+
"cs-fix": "Fix the coding style of a PHP file or directory, which you must specify.",
|
401 |
+
"test": "Launches the preconfigured PHPUnit"
|
402 |
+
}
|
403 |
+
},
|
404 |
+
"installation-source": "dist",
|
405 |
+
"autoload": {
|
406 |
+
"psr-4": {
|
407 |
+
"FileUtil\\": "src/"
|
408 |
+
}
|
409 |
+
},
|
410 |
+
"notification-url": "https://packagist.org/downloads/",
|
411 |
+
"license": [
|
412 |
+
"MIT"
|
413 |
+
],
|
414 |
+
"authors": [
|
415 |
+
{
|
416 |
+
"name": "Bjørn Rosell",
|
417 |
+
"homepage": "https://www.bitwise-it.dk/contact",
|
418 |
+
"role": "Project Author"
|
419 |
+
}
|
420 |
+
],
|
421 |
+
"description": "Functions for dealing with files and paths",
|
422 |
+
"keywords": [
|
423 |
+
"files",
|
424 |
+
"path",
|
425 |
+
"util"
|
426 |
+
],
|
427 |
+
"support": {
|
428 |
+
"issues": "https://github.com/rosell-dk/file-util/issues",
|
429 |
+
"source": "https://github.com/rosell-dk/file-util/tree/0.1.1"
|
430 |
+
},
|
431 |
+
"funding": [
|
432 |
+
{
|
433 |
+
"url": "https://github.com/rosell-dk",
|
434 |
+
"type": "github"
|
435 |
+
},
|
436 |
+
{
|
437 |
+
"url": "https://ko-fi.com/rosell",
|
438 |
+
"type": "ko_fi"
|
439 |
+
}
|
440 |
+
],
|
441 |
+
"install-path": "../rosell-dk/file-util"
|
442 |
+
},
|
443 |
{
|
444 |
"name": "rosell-dk/htaccess-capability-tester",
|
445 |
"version": "0.9.1",
|
518 |
},
|
519 |
{
|
520 |
"name": "rosell-dk/image-mime-type-guesser",
|
521 |
+
"version": "1.1.1",
|
522 |
+
"version_normalized": "1.1.1.0",
|
523 |
"source": {
|
524 |
"type": "git",
|
525 |
"url": "https://github.com/rosell-dk/image-mime-type-guesser.git",
|
526 |
+
"reference": "72f7040e95a78937ae2edece452530224fcacea6"
|
527 |
},
|
528 |
"dist": {
|
529 |
"type": "zip",
|
530 |
+
"url": "https://api.github.com/repos/rosell-dk/image-mime-type-guesser/zipball/72f7040e95a78937ae2edece452530224fcacea6",
|
531 |
+
"reference": "72f7040e95a78937ae2edece452530224fcacea6",
|
532 |
"shasum": ""
|
533 |
},
|
534 |
+
"require": {
|
535 |
+
"php": "^5.6 | ^7.0 | ^8.0",
|
536 |
+
"rosell-dk/image-mime-type-sniffer": "^1.0"
|
537 |
+
},
|
538 |
"require-dev": {
|
539 |
"friendsofphp/php-cs-fixer": "^2.11",
|
540 |
+
"phpstan/phpstan": "^1.5",
|
541 |
"phpunit/phpunit": "^9.3",
|
542 |
"squizlabs/php_codesniffer": "3.*"
|
543 |
},
|
544 |
+
"time": "2022-05-19T09:57:15+00:00",
|
545 |
"type": "library",
|
546 |
"extra": {
|
547 |
"scripts-descriptions": {
|
579 |
],
|
580 |
"support": {
|
581 |
"issues": "https://github.com/rosell-dk/image-mime-type-guesser/issues",
|
582 |
+
"source": "https://github.com/rosell-dk/image-mime-type-guesser/tree/1.1.1"
|
583 |
},
|
584 |
"funding": [
|
585 |
{
|
593 |
],
|
594 |
"install-path": "../rosell-dk/image-mime-type-guesser"
|
595 |
},
|
596 |
+
{
|
597 |
+
"name": "rosell-dk/image-mime-type-sniffer",
|
598 |
+
"version": "1.1.1",
|
599 |
+
"version_normalized": "1.1.1.0",
|
600 |
+
"source": {
|
601 |
+
"type": "git",
|
602 |
+
"url": "https://github.com/rosell-dk/image-mime-type-sniffer.git",
|
603 |
+
"reference": "9ed14cc5d2c14c417660a4dd1946b5f056494691"
|
604 |
+
},
|
605 |
+
"dist": {
|
606 |
+
"type": "zip",
|
607 |
+
"url": "https://api.github.com/repos/rosell-dk/image-mime-type-sniffer/zipball/9ed14cc5d2c14c417660a4dd1946b5f056494691",
|
608 |
+
"reference": "9ed14cc5d2c14c417660a4dd1946b5f056494691",
|
609 |
+
"shasum": ""
|
610 |
+
},
|
611 |
+
"require": {
|
612 |
+
"php": ">=5.4"
|
613 |
+
},
|
614 |
+
"require-dev": {
|
615 |
+
"friendsofphp/php-cs-fixer": "^2.11",
|
616 |
+
"mikey179/vfsstream": "^1.6",
|
617 |
+
"phpstan/phpstan": "^1.5",
|
618 |
+
"phpunit/phpunit": "^9.3",
|
619 |
+
"squizlabs/php_codesniffer": "3.*"
|
620 |
+
},
|
621 |
+
"time": "2022-04-20T14:31:25+00:00",
|
622 |
+
"type": "library",
|
623 |
+
"extra": {
|
624 |
+
"scripts-descriptions": {
|
625 |
+
"ci": "Run tests before CI",
|
626 |
+
"phpcs": "Checks coding styles (PSR2) of file/dir, which you must supply. To check all, supply 'src'",
|
627 |
+
"phpcbf": "Fix coding styles (PSR2) of file/dir, which you must supply. To fix all, supply 'src'",
|
628 |
+
"cs-fix-all": "Fix the coding style of all the source files, to comply with the PSR-2 coding standard",
|
629 |
+
"cs-fix": "Fix the coding style of a PHP file or directory, which you must specify.",
|
630 |
+
"test": "Launches the preconfigured PHPUnit"
|
631 |
+
}
|
632 |
+
},
|
633 |
+
"installation-source": "dist",
|
634 |
+
"autoload": {
|
635 |
+
"psr-4": {
|
636 |
+
"ImageMimeTypeSniffer\\": "src/"
|
637 |
+
}
|
638 |
+
},
|
639 |
+
"notification-url": "https://packagist.org/downloads/",
|
640 |
+
"license": [
|
641 |
+
"MIT"
|
642 |
+
],
|
643 |
+
"authors": [
|
644 |
+
{
|
645 |
+
"name": "Bjørn Rosell",
|
646 |
+
"homepage": "https://www.bitwise-it.dk/contact",
|
647 |
+
"role": "Project Author"
|
648 |
+
}
|
649 |
+
],
|
650 |
+
"description": "Sniff mime type (images only)",
|
651 |
+
"keywords": [
|
652 |
+
"image",
|
653 |
+
"images",
|
654 |
+
"mime",
|
655 |
+
"mime type"
|
656 |
+
],
|
657 |
+
"support": {
|
658 |
+
"issues": "https://github.com/rosell-dk/image-mime-type-sniffer/issues",
|
659 |
+
"source": "https://github.com/rosell-dk/image-mime-type-sniffer/tree/1.1.1"
|
660 |
+
},
|
661 |
+
"funding": [
|
662 |
+
{
|
663 |
+
"url": "https://github.com/rosell-dk",
|
664 |
+
"type": "github"
|
665 |
+
},
|
666 |
+
{
|
667 |
+
"url": "https://ko-fi.com/rosell",
|
668 |
+
"type": "ko_fi"
|
669 |
+
}
|
670 |
+
],
|
671 |
+
"install-path": "../rosell-dk/image-mime-type-sniffer"
|
672 |
+
},
|
673 |
+
{
|
674 |
+
"name": "rosell-dk/locate-binaries",
|
675 |
+
"version": "1.0",
|
676 |
+
"version_normalized": "1.0.0.0",
|
677 |
+
"source": {
|
678 |
+
"type": "git",
|
679 |
+
"url": "https://github.com/rosell-dk/locate-binaries.git",
|
680 |
+
"reference": "bd2f493383ecd55aa519828dd2898e30f3b9cbb0"
|
681 |
+
},
|
682 |
+
"dist": {
|
683 |
+
"type": "zip",
|
684 |
+
"url": "https://api.github.com/repos/rosell-dk/locate-binaries/zipball/bd2f493383ecd55aa519828dd2898e30f3b9cbb0",
|
685 |
+
"reference": "bd2f493383ecd55aa519828dd2898e30f3b9cbb0",
|
686 |
+
"shasum": ""
|
687 |
+
},
|
688 |
+
"require": {
|
689 |
+
"php": ">=5.6",
|
690 |
+
"rosell-dk/exec-with-fallback": "^1.0.0",
|
691 |
+
"rosell-dk/file-util": "^0.1.0"
|
692 |
+
},
|
693 |
+
"require-dev": {
|
694 |
+
"friendsofphp/php-cs-fixer": "^2.11",
|
695 |
+
"phpstan/phpstan": "^1.5",
|
696 |
+
"phpunit/phpunit": "^9.3",
|
697 |
+
"squizlabs/php_codesniffer": "3.*"
|
698 |
+
},
|
699 |
+
"time": "2022-04-20T07:20:07+00:00",
|
700 |
+
"type": "library",
|
701 |
+
"extra": {
|
702 |
+
"scripts-descriptions": {
|
703 |
+
"ci": "Run tests before CI",
|
704 |
+
"phpcs": "Checks coding styles (PSR2) of file/dir, which you must supply. To check all, supply 'src'",
|
705 |
+
"phpcbf": "Fix coding styles (PSR2) of file/dir, which you must supply. To fix all, supply 'src'",
|
706 |
+
"cs-fix-all": "Fix the coding style of all the source files, to comply with the PSR-2 coding standard",
|
707 |
+
"cs-fix": "Fix the coding style of a PHP file or directory, which you must specify.",
|
708 |
+
"test": "Launches the preconfigured PHPUnit"
|
709 |
+
}
|
710 |
+
},
|
711 |
+
"installation-source": "dist",
|
712 |
+
"autoload": {
|
713 |
+
"psr-4": {
|
714 |
+
"LocateBinaries\\": "src/"
|
715 |
+
}
|
716 |
+
},
|
717 |
+
"notification-url": "https://packagist.org/downloads/",
|
718 |
+
"license": [
|
719 |
+
"MIT"
|
720 |
+
],
|
721 |
+
"authors": [
|
722 |
+
{
|
723 |
+
"name": "Bjørn Rosell",
|
724 |
+
"homepage": "https://www.bitwise-it.dk/contact",
|
725 |
+
"role": "Project Author"
|
726 |
+
}
|
727 |
+
],
|
728 |
+
"description": "Locate a binaries by means of exec() or similar",
|
729 |
+
"keywords": [
|
730 |
+
"binary",
|
731 |
+
"discover",
|
732 |
+
"locate",
|
733 |
+
"whereis",
|
734 |
+
"which"
|
735 |
+
],
|
736 |
+
"support": {
|
737 |
+
"issues": "https://github.com/rosell-dk/locate-binaries/issues",
|
738 |
+
"source": "https://github.com/rosell-dk/locate-binaries/tree/1.0"
|
739 |
+
},
|
740 |
+
"funding": [
|
741 |
+
{
|
742 |
+
"url": "https://github.com/rosell-dk",
|
743 |
+
"type": "github"
|
744 |
+
},
|
745 |
+
{
|
746 |
+
"url": "https://ko-fi.com/rosell",
|
747 |
+
"type": "ko_fi"
|
748 |
+
}
|
749 |
+
],
|
750 |
+
"install-path": "../rosell-dk/locate-binaries"
|
751 |
+
},
|
752 |
{
|
753 |
"name": "rosell-dk/webp-convert",
|
754 |
+
"version": "2.9.2",
|
755 |
+
"version_normalized": "2.9.2.0",
|
756 |
"source": {
|
757 |
"type": "git",
|
758 |
"url": "https://github.com/rosell-dk/webp-convert.git",
|
759 |
+
"reference": "5ccba85ebe3b28ae229459fd0baed25314616ac9"
|
760 |
},
|
761 |
"dist": {
|
762 |
"type": "zip",
|
763 |
+
"url": "https://api.github.com/repos/rosell-dk/webp-convert/zipball/5ccba85ebe3b28ae229459fd0baed25314616ac9",
|
764 |
+
"reference": "5ccba85ebe3b28ae229459fd0baed25314616ac9",
|
765 |
"shasum": ""
|
766 |
},
|
767 |
"require": {
|
768 |
"php": "^5.6 | ^7.0 | ^8.0",
|
769 |
"rosell-dk/exec-with-fallback": "^1.0.0",
|
770 |
+
"rosell-dk/image-mime-type-guesser": "^1.1.1",
|
771 |
+
"rosell-dk/locate-binaries": "^1.0"
|
772 |
},
|
773 |
"require-dev": {
|
774 |
"friendsofphp/php-cs-fixer": "^2.11",
|
775 |
+
"phpstan/phpstan": "^1.5",
|
776 |
"phpunit/phpunit": "^9.3",
|
777 |
"squizlabs/php_codesniffer": "3.*"
|
778 |
},
|
782 |
"ext-vips": "to use Vips extension for converting.",
|
783 |
"php-stan/php-stan": "Suggested for dev, in order to analyse code before committing"
|
784 |
},
|
785 |
+
"time": "2022-05-19T13:56:36+00:00",
|
786 |
"type": "library",
|
787 |
"extra": {
|
788 |
"scripts-descriptions": {
|
831 |
],
|
832 |
"support": {
|
833 |
"issues": "https://github.com/rosell-dk/webp-convert/issues",
|
834 |
+
"source": "https://github.com/rosell-dk/webp-convert/tree/2.9.2"
|
835 |
},
|
836 |
"funding": [
|
837 |
{
|
vendor/composer/installed.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
'type' => 'wordpress-plugin',
|
6 |
'install_path' => __DIR__ . '/../../',
|
7 |
'aliases' => array(),
|
8 |
-
'reference' => '
|
9 |
'name' => 'rosell-dk/webp-express',
|
10 |
'dev' => true,
|
11 |
),
|
@@ -46,6 +46,15 @@
|
|
46 |
'reference' => 'f88a6b29abd0b580566056b7c1eb0434eb5db20d',
|
47 |
'dev_requirement' => false,
|
48 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
'rosell-dk/htaccess-capability-tester' => array(
|
50 |
'pretty_version' => '0.9.1',
|
51 |
'version' => '0.9.1.0',
|
@@ -56,21 +65,39 @@
|
|
56 |
'dev_requirement' => false,
|
57 |
),
|
58 |
'rosell-dk/image-mime-type-guesser' => array(
|
59 |
-
'pretty_version' => '
|
60 |
-
'version' => '
|
61 |
'type' => 'library',
|
62 |
'install_path' => __DIR__ . '/../rosell-dk/image-mime-type-guesser',
|
63 |
'aliases' => array(),
|
64 |
-
'reference' => '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
'dev_requirement' => false,
|
66 |
),
|
67 |
'rosell-dk/webp-convert' => array(
|
68 |
-
'pretty_version' => '2.9.
|
69 |
-
'version' => '2.9.
|
70 |
'type' => 'library',
|
71 |
'install_path' => __DIR__ . '/../rosell-dk/webp-convert',
|
72 |
'aliases' => array(),
|
73 |
-
'reference' => '
|
74 |
'dev_requirement' => false,
|
75 |
),
|
76 |
'rosell-dk/webp-convert-cloud-service' => array(
|
@@ -88,7 +115,7 @@
|
|
88 |
'type' => 'wordpress-plugin',
|
89 |
'install_path' => __DIR__ . '/../../',
|
90 |
'aliases' => array(),
|
91 |
-
'reference' => '
|
92 |
'dev_requirement' => false,
|
93 |
),
|
94 |
'roundcube/plugin-installer' => array(
|
5 |
'type' => 'wordpress-plugin',
|
6 |
'install_path' => __DIR__ . '/../../',
|
7 |
'aliases' => array(),
|
8 |
+
'reference' => 'b03c668fcb064239f0db2faa567a29773f5b902c',
|
9 |
'name' => 'rosell-dk/webp-express',
|
10 |
'dev' => true,
|
11 |
),
|
46 |
'reference' => 'f88a6b29abd0b580566056b7c1eb0434eb5db20d',
|
47 |
'dev_requirement' => false,
|
48 |
),
|
49 |
+
'rosell-dk/file-util' => array(
|
50 |
+
'pretty_version' => '0.1.1',
|
51 |
+
'version' => '0.1.1.0',
|
52 |
+
'type' => 'library',
|
53 |
+
'install_path' => __DIR__ . '/../rosell-dk/file-util',
|
54 |
+
'aliases' => array(),
|
55 |
+
'reference' => '2ff895308c37f448b34b031cfbfd8e45f43936fd',
|
56 |
+
'dev_requirement' => false,
|
57 |
+
),
|
58 |
'rosell-dk/htaccess-capability-tester' => array(
|
59 |
'pretty_version' => '0.9.1',
|
60 |
'version' => '0.9.1.0',
|
65 |
'dev_requirement' => false,
|
66 |
),
|
67 |
'rosell-dk/image-mime-type-guesser' => array(
|
68 |
+
'pretty_version' => '1.1.1',
|
69 |
+
'version' => '1.1.1.0',
|
70 |
'type' => 'library',
|
71 |
'install_path' => __DIR__ . '/../rosell-dk/image-mime-type-guesser',
|
72 |
'aliases' => array(),
|
73 |
+
'reference' => '72f7040e95a78937ae2edece452530224fcacea6',
|
74 |
+
'dev_requirement' => false,
|
75 |
+
),
|
76 |
+
'rosell-dk/image-mime-type-sniffer' => array(
|
77 |
+
'pretty_version' => '1.1.1',
|
78 |
+
'version' => '1.1.1.0',
|
79 |
+
'type' => 'library',
|
80 |
+
'install_path' => __DIR__ . '/../rosell-dk/image-mime-type-sniffer',
|
81 |
+
'aliases' => array(),
|
82 |
+
'reference' => '9ed14cc5d2c14c417660a4dd1946b5f056494691',
|
83 |
+
'dev_requirement' => false,
|
84 |
+
),
|
85 |
+
'rosell-dk/locate-binaries' => array(
|
86 |
+
'pretty_version' => '1.0',
|
87 |
+
'version' => '1.0.0.0',
|
88 |
+
'type' => 'library',
|
89 |
+
'install_path' => __DIR__ . '/../rosell-dk/locate-binaries',
|
90 |
+
'aliases' => array(),
|
91 |
+
'reference' => 'bd2f493383ecd55aa519828dd2898e30f3b9cbb0',
|
92 |
'dev_requirement' => false,
|
93 |
),
|
94 |
'rosell-dk/webp-convert' => array(
|
95 |
+
'pretty_version' => '2.9.2',
|
96 |
+
'version' => '2.9.2.0',
|
97 |
'type' => 'library',
|
98 |
'install_path' => __DIR__ . '/../rosell-dk/webp-convert',
|
99 |
'aliases' => array(),
|
100 |
+
'reference' => '5ccba85ebe3b28ae229459fd0baed25314616ac9',
|
101 |
'dev_requirement' => false,
|
102 |
),
|
103 |
'rosell-dk/webp-convert-cloud-service' => array(
|
115 |
'type' => 'wordpress-plugin',
|
116 |
'install_path' => __DIR__ . '/../../',
|
117 |
'aliases' => array(),
|
118 |
+
'reference' => 'b03c668fcb064239f0db2faa567a29773f5b902c',
|
119 |
'dev_requirement' => false,
|
120 |
),
|
121 |
'roundcube/plugin-installer' => array(
|
vendor/rosell-dk/file-util/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2018 Bjørn Rosell
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6 |
+
|
7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8 |
+
|
9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
vendor/rosell-dk/file-util/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# File Util
|
2 |
+
|
3 |
+
[![Build Status](https://github.com/rosell-dk/file-util/workflows/build/badge.svg)](https://github.com/rosell-dk/file-util/actions/workflows/php.yml)
|
4 |
+
[![Software License](https://img.shields.io/badge/license-MIT-418677.svg)](https://github.com/rosell-dk/file-util/blob/master/LICENSE)
|
5 |
+
[![Coverage](https://img.shields.io/endpoint?url=https://little-b.it/file-util/code-coverage/coverage-badge.json)](http://little-b.it/file-util/code-coverage/coverage/index.html)
|
6 |
+
[![Latest Stable Version](https://img.shields.io/packagist/v/rosell-dk/file-util.svg)](https://packagist.org/packages/rosell-dk/file-util)
|
7 |
+
[![Minimum PHP Version](https://img.shields.io/packagist/php-v/rosell-dk/file-util)](https://php.net)
|
8 |
+
|
9 |
+
Just a bunch of handy methods for dealing with files and paths:
|
10 |
+
|
11 |
+
|
12 |
+
- *FileExists::fileExists($path)*:\
|
13 |
+
A well-behaved version of *file_exists* that throws upon failure rather than emitting a warning
|
14 |
+
|
15 |
+
- *FileExists::fileExistsTryHarder($path)*:\
|
16 |
+
Also well-behaved. Tries FileExists::fileExists(). In case of failure, tries exec()-based implementation
|
17 |
+
|
18 |
+
- *PathValidator::checkPath($path)*:\
|
19 |
+
Check if path looks valid and doesn't contain suspecious patterns
|
20 |
+
|
21 |
+
- *PathValidator::checkFilePathIsRegularFile($path)*:\
|
22 |
+
Check if path points to a regular file (and doesnt match suspecious patterns)
|
vendor/rosell-dk/file-util/composer.json
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "rosell-dk/file-util",
|
3 |
+
"description": "Functions for dealing with files and paths",
|
4 |
+
"type": "library",
|
5 |
+
"license": "MIT",
|
6 |
+
"keywords": ["files", "path", "util"],
|
7 |
+
"scripts": {
|
8 |
+
"ci": [
|
9 |
+
"@test",
|
10 |
+
"@phpcs-all",
|
11 |
+
"@composer validate --no-check-all --strict",
|
12 |
+
"@phpstan-global"
|
13 |
+
],
|
14 |
+
"phpunit": "phpunit --coverage-text",
|
15 |
+
"test": "phpunit --coverage-text=build/coverage.txt --coverage-clover=build/coverage.clover --coverage-html=build/coverage --whitelist=src tests",
|
16 |
+
"test-no-cov": "phpunit --no-coverage tests",
|
17 |
+
"test-41": "phpunit --no-coverage --configuration 'phpunit-41.xml.dist'",
|
18 |
+
"test-with-coverage": "phpunit --coverage-text --configuration 'phpunit-with-coverage.xml.dist'",
|
19 |
+
"test-41-with-coverage": "phpunit --coverage-text --configuration 'phpunit-41.xml.dist'",
|
20 |
+
"cs-fix-all": [
|
21 |
+
"php-cs-fixer fix src"
|
22 |
+
],
|
23 |
+
"cs-fix": "php-cs-fixer fix",
|
24 |
+
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
25 |
+
"phpcs": "phpcs --standard=phpcs-ruleset.xml",
|
26 |
+
"phpcs-all": "phpcs --standard=phpcs-ruleset.xml src",
|
27 |
+
"phpcbf": "phpcbf --standard=PSR2",
|
28 |
+
"phpstan": "vendor/bin/phpstan analyse src --level=4",
|
29 |
+
"phpstan-global-old": "~/.composer/vendor/bin/phpstan analyse src --level=4",
|
30 |
+
"phpstan-global": "~/.config/composer/vendor/bin/phpstan analyse src --level=4"
|
31 |
+
},
|
32 |
+
"extra": {
|
33 |
+
"scripts-descriptions": {
|
34 |
+
"ci": "Run tests before CI",
|
35 |
+
"phpcs": "Checks coding styles (PSR2) of file/dir, which you must supply. To check all, supply 'src'",
|
36 |
+
"phpcbf": "Fix coding styles (PSR2) of file/dir, which you must supply. To fix all, supply 'src'",
|
37 |
+
"cs-fix-all": "Fix the coding style of all the source files, to comply with the PSR-2 coding standard",
|
38 |
+
"cs-fix": "Fix the coding style of a PHP file or directory, which you must specify.",
|
39 |
+
"test": "Launches the preconfigured PHPUnit"
|
40 |
+
}
|
41 |
+
},
|
42 |
+
"autoload": {
|
43 |
+
"psr-4": { "FileUtil\\": "src/" }
|
44 |
+
},
|
45 |
+
"autoload-dev": {
|
46 |
+
"psr-4": { "FileUtil\\Tests\\": "tests/" }
|
47 |
+
},
|
48 |
+
"authors": [
|
49 |
+
{
|
50 |
+
"name": "Bjørn Rosell",
|
51 |
+
"homepage": "https://www.bitwise-it.dk/contact",
|
52 |
+
"role": "Project Author"
|
53 |
+
}
|
54 |
+
],
|
55 |
+
"require": {
|
56 |
+
"php": ">=5.4",
|
57 |
+
"rosell-dk/exec-with-fallback": "^1.0.0"
|
58 |
+
},
|
59 |
+
"require-dev": {
|
60 |
+
"friendsofphp/php-cs-fixer": "^2.11",
|
61 |
+
"phpunit/phpunit": "^9.3",
|
62 |
+
"squizlabs/php_codesniffer": "3.*",
|
63 |
+
"phpstan/phpstan": "^1.5",
|
64 |
+
"mikey179/vfsstream": "^1.6"
|
65 |
+
},
|
66 |
+
"config": {
|
67 |
+
"sort-packages": true
|
68 |
+
}
|
69 |
+
}
|
vendor/rosell-dk/file-util/phpcs-ruleset.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Custom Standard">
|
3 |
+
<description>PSR2 without line ending rule - let git manage the EOL cross the platforms</description>
|
4 |
+
<rule ref="PSR2" />
|
5 |
+
<rule ref="Generic.Files.LineEndings">
|
6 |
+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
|
7 |
+
</rule>
|
8 |
+
</ruleset>
|
vendor/rosell-dk/{webp-convert/src/Helpers → file-util/src}/FileExists.php
RENAMED
@@ -1,15 +1,14 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace
|
4 |
|
5 |
-
use
|
6 |
|
7 |
/**
|
8 |
* A fileExist function free of deception
|
9 |
*
|
10 |
-
* @package
|
11 |
* @author Bjørn Rosell <it@rosell.dk>
|
12 |
-
* @since Class available since Release 2.3.0
|
13 |
*/
|
14 |
class FileExists
|
15 |
{
|
@@ -38,18 +37,18 @@ class FileExists
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
* A well behaved replacement for file_exist that throws upon failure rather than
|
42 |
*
|
43 |
-
* @throws \Exception
|
44 |
-
* @return boolean
|
45 |
*/
|
46 |
-
public static function
|
47 |
{
|
48 |
// There is a challenges here:
|
49 |
// We want to suppress warnings, but at the same time we want to know that it happened.
|
50 |
// We achieve this by registering an error handler
|
51 |
set_error_handler(
|
52 |
-
array('
|
53 |
E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE
|
54 |
);
|
55 |
self::$lastWarning = null;
|
@@ -73,31 +72,6 @@ class FileExists
|
|
73 |
throw new \Exception($errstr, $errno);
|
74 |
}
|
75 |
|
76 |
-
/**
|
77 |
-
* A fileExist based on an exec call.
|
78 |
-
*
|
79 |
-
* @throws \Exception If exec cannot be called
|
80 |
-
* @return boolean|null True if file exists. False if it doesn't.
|
81 |
-
*/
|
82 |
-
public static function fileExistsUsingExec($path)
|
83 |
-
{
|
84 |
-
if (!ExecWithFallback::anyAvailable()) {
|
85 |
-
throw new \Exception(
|
86 |
-
'cannot determine if file exists using exec() or similar - the function is unavailable'
|
87 |
-
);
|
88 |
-
}
|
89 |
-
|
90 |
-
// Lets try to find out by executing "ls path/to/cwebp"
|
91 |
-
ExecWithFallback::exec('ls ' . $path, $output, $returnCode);
|
92 |
-
if (($returnCode == 0) && (isset($output[0]))) {
|
93 |
-
return true;
|
94 |
-
}
|
95 |
-
|
96 |
-
// We assume that "ls" command is general available!
|
97 |
-
// As that failed, we can conclude the file does not exist.
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
|
101 |
/**
|
102 |
* A fileExist doing the best it can.
|
103 |
*
|
@@ -107,10 +81,10 @@ class FileExists
|
|
107 |
public static function fileExistsTryHarder($path)
|
108 |
{
|
109 |
try {
|
110 |
-
$result = self::
|
111 |
} catch (\Exception $e) {
|
112 |
try {
|
113 |
-
$result =
|
114 |
} catch (\Exception $e) {
|
115 |
throw new \Exception('Cannot determine if file exists or not');
|
116 |
} catch (\Throwable $e) {
|
1 |
<?php
|
2 |
|
3 |
+
namespace FileUtil;
|
4 |
|
5 |
+
use FileUtil\FileExistsUsingExec;
|
6 |
|
7 |
/**
|
8 |
* A fileExist function free of deception
|
9 |
*
|
10 |
+
* @package FileUtil
|
11 |
* @author Bjørn Rosell <it@rosell.dk>
|
|
|
12 |
*/
|
13 |
class FileExists
|
14 |
{
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* A well behaved replacement for file_exist that throws upon failure rather than emitting a warning.
|
41 |
*
|
42 |
+
* @throws \Exception Throws an exception in case file_exists emits a warning
|
43 |
+
* @return boolean True if file exists. False if it doesn't.
|
44 |
*/
|
45 |
+
public static function fileExists($path)
|
46 |
{
|
47 |
// There is a challenges here:
|
48 |
// We want to suppress warnings, but at the same time we want to know that it happened.
|
49 |
// We achieve this by registering an error handler
|
50 |
set_error_handler(
|
51 |
+
array('FileUtil\FileExists', "warningHandler"),
|
52 |
E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE
|
53 |
);
|
54 |
self::$lastWarning = null;
|
72 |
throw new \Exception($errstr, $errno);
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
* A fileExist doing the best it can.
|
77 |
*
|
81 |
public static function fileExistsTryHarder($path)
|
82 |
{
|
83 |
try {
|
84 |
+
$result = self::fileExists($path);
|
85 |
} catch (\Exception $e) {
|
86 |
try {
|
87 |
+
$result = FileExistsUsingExec::fileExists($path);
|
88 |
} catch (\Exception $e) {
|
89 |
throw new \Exception('Cannot determine if file exists or not');
|
90 |
} catch (\Throwable $e) {
|
vendor/rosell-dk/file-util/src/FileExistsUsingExec.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FileUtil;
|
4 |
+
|
5 |
+
use ExecWithFallback\ExecWithFallback;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* A fileExist implementation using exec()
|
9 |
+
*
|
10 |
+
* @package FileUtil
|
11 |
+
* @author Bjørn Rosell <it@rosell.dk>
|
12 |
+
*/
|
13 |
+
class FileExistsUsingExec
|
14 |
+
{
|
15 |
+
|
16 |
+
/**
|
17 |
+
* A fileExist based on an exec call.
|
18 |
+
*
|
19 |
+
* @throws \Exception If exec cannot be called
|
20 |
+
* @return boolean|null True if file exists. False if it doesn't.
|
21 |
+
*/
|
22 |
+
public static function fileExists($path)
|
23 |
+
{
|
24 |
+
if (!ExecWithFallback::anyAvailable()) {
|
25 |
+
throw new \Exception(
|
26 |
+
'cannot determine if file exists using exec() or similar - the function is unavailable'
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
// Lets try to find out by executing "ls path/to/cwebp"
|
31 |
+
ExecWithFallback::exec('ls ' . $path, $output, $returnCode);
|
32 |
+
if (($returnCode == 0) && (isset($output[0]))) {
|
33 |
+
return true;
|
34 |
+
}
|
35 |
+
|
36 |
+
// We assume that "ls" command is general available!
|
37 |
+
// As that failed, we can conclude the file does not exist.
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
}
|
vendor/rosell-dk/file-util/src/PathValidator.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FileUtil;
|
4 |
+
|
5 |
+
use FileUtil\FileExists;
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @package FileUtil
|
11 |
+
* @author Bjørn Rosell <it@rosell.dk>
|
12 |
+
*/
|
13 |
+
class PathValidator
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Check if path looks valid and doesn't contain suspecious patterns.
|
17 |
+
|
18 |
+
* The path must meet the following criteria:
|
19 |
+
*
|
20 |
+
* - It must be a string
|
21 |
+
* - No NUL character
|
22 |
+
* - No control characters between 0-20
|
23 |
+
* - No phar stream wrapper
|
24 |
+
* - No php stream wrapper
|
25 |
+
* - No glob stream wrapper
|
26 |
+
* - Not empty path
|
27 |
+
*
|
28 |
+
* @throws \Exception In case the path doesn't meet all criteria
|
29 |
+
*/
|
30 |
+
public static function checkPath($path)
|
31 |
+
{
|
32 |
+
if (gettype($path) !== 'string') {
|
33 |
+
throw new \Exception('File path must be string');
|
34 |
+
}
|
35 |
+
if (strpos($path, chr(0)) !== false) {
|
36 |
+
throw new \Exception('NUL character is not allowed in file path!');
|
37 |
+
}
|
38 |
+
if (preg_match('#[\x{0}-\x{1f}]#', $path)) {
|
39 |
+
// prevents line feed, new line, tab, charater return, tab, ets.
|
40 |
+
throw new \Exception('Control characters #0-#20 not allowed in file path!');
|
41 |
+
}
|
42 |
+
// Prevent phar stream wrappers (security threat)
|
43 |
+
if (preg_match('#^phar://#', $path)) {
|
44 |
+
throw new \Exception('phar stream wrappers are not allowed in file path');
|
45 |
+
}
|
46 |
+
if (preg_match('#^(php|glob)://#', $path)) {
|
47 |
+
throw new \Exception('php and glob stream wrappers are not allowed in file path');
|
48 |
+
}
|
49 |
+
if (empty($path)) {
|
50 |
+
throw new \Exception('File path is empty!');
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Check if path points to a regular file (and doesnt match suspecious patterns).
|
56 |
+
*
|
57 |
+
* @throws \Exception In case the path doesn't point to a regular file or matches suspecious patterns
|
58 |
+
*/
|
59 |
+
public static function checkFilePathIsRegularFile($path)
|
60 |
+
{
|
61 |
+
self::checkPath($path);
|
62 |
+
|
63 |
+
if (!FileExists::fileExists($path)) {
|
64 |
+
throw new \Exception('File does not exist');
|
65 |
+
}
|
66 |
+
if (@is_dir($path)) {
|
67 |
+
throw new \Exception('Expected a regular file, not a dir');
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
vendor/rosell-dk/image-mime-type-guesser/README.md
CHANGED
@@ -2,10 +2,11 @@
|
|
2 |
|
3 |
[![Latest Stable Version](https://img.shields.io/packagist/v/rosell-dk/image-mime-type-guesser.svg?style=flat-square)](https://packagist.org/packages/rosell-dk/image-mime-type-guesser)
|
4 |
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg?style=flat-square)](https://php.net)
|
5 |
-
[![Build Status](https://img.shields.io/github/workflow/status/rosell-dk/image-mime-type-guesser/PHP?style=flat-square)](https://github.com/rosell-dk/image-mime-type-guesser/actions/workflows/php.yml)
|
6 |
-
[![Coverage
|
7 |
-
[![Quality Score](https://img.shields.io/scrutinizer/g/rosell-dk/image-mime-type-guesser.svg?style=flat-square)](https://scrutinizer-ci.com/g/rosell-dk/image-mime-type-guesser/)
|
8 |
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/rosell-dk/image-mime-type-guesser/blob/master/LICENSE)
|
|
|
|
|
9 |
|
10 |
|
11 |
*Detect / guess mime type of an image*
|
@@ -18,8 +19,8 @@ And perhaps you also want to know the mime type of the image?<br>
|
|
18 |
Ok, actually the library cannot offer mime type detection for images which works *on all platforms*, but it can try a whole stack of methods and optionally fall back to guess from the file extension.
|
19 |
|
20 |
The stack of detect methods are currently (and in that order):
|
|
|
21 |
- [`finfo`](https://www.php.net/manual/en/class.finfo.php) *Requires fileinfo extension to be enabled. (PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0)*
|
22 |
-
- Our signature sniffer (based on [this code](http://phil.lavin.me.uk/2011/12/php-accurately-detecting-the-type-of-a-file/)) *Works on all platforms (PHP 4, PHP 5, PHP 7, PHP 8). Only detects png, gif, jpeg and webp*
|
23 |
- [`exif_imagetype`](https://www.php.net/manual/en/function.exif-imagetype.php) *Requires that PHP is compiled with exif (PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)*
|
24 |
- [`mime_content_type`](https://www.php.net/manual/en/function.mime-content-type.php) *Requires fileinfo. (PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)*
|
25 |
|
@@ -29,7 +30,10 @@ Besides the detection methods, the library also comes with a method for mapping
|
|
29 |
|
30 |
## Installation
|
31 |
|
32 |
-
Install with composer
|
|
|
|
|
|
|
33 |
|
34 |
## Usage
|
35 |
|
@@ -98,3 +102,9 @@ Other sniffers:
|
|
98 |
- https://github.com/Intervention/mimesniffer
|
99 |
- https://github.com/zjsxwc/mime-type-sniffer
|
100 |
- https://github.com/Tinram/File-Identifier
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
[![Latest Stable Version](https://img.shields.io/packagist/v/rosell-dk/image-mime-type-guesser.svg?style=flat-square)](https://packagist.org/packages/rosell-dk/image-mime-type-guesser)
|
4 |
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg?style=flat-square)](https://php.net)
|
5 |
+
[![Build Status](https://img.shields.io/github/workflow/status/rosell-dk/image-mime-type-guesser/PHP?logo=GitHub&style=flat-square)](https://github.com/rosell-dk/image-mime-type-guesser/actions/workflows/php.yml)
|
6 |
+
[![Coverage](https://img.shields.io/endpoint?url=https://little-b.it/image-mime-type-guesser/code-coverage/coverage-badge.json)](http://little-b.it/image-mime-type-guesser/code-coverage/coverage/index.html)
|
|
|
7 |
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/rosell-dk/image-mime-type-guesser/blob/master/LICENSE)
|
8 |
+
[![Monthly Downloads](http://poser.pugx.org/rosell-dk/image-mime-type-guesser/d/monthly)](https://packagist.org/packages/rosell-dk/image-mime-type-guesser)
|
9 |
+
[![Dependents](http://poser.pugx.org/rosell-dk/image-mime-type-guesser/dependents)](https://packagist.org/packages/rosell-dk/image-mime-type-guesser/dependents?order_by=downloads)
|
10 |
|
11 |
|
12 |
*Detect / guess mime type of an image*
|
19 |
Ok, actually the library cannot offer mime type detection for images which works *on all platforms*, but it can try a whole stack of methods and optionally fall back to guess from the file extension.
|
20 |
|
21 |
The stack of detect methods are currently (and in that order):
|
22 |
+
- [This signature sniffer](https://github.com/rosell-dk/image-mime-type-sniffer) *Does not require any extensions. Recognizes popular image formats only*
|
23 |
- [`finfo`](https://www.php.net/manual/en/class.finfo.php) *Requires fileinfo extension to be enabled. (PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0)*
|
|
|
24 |
- [`exif_imagetype`](https://www.php.net/manual/en/function.exif-imagetype.php) *Requires that PHP is compiled with exif (PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)*
|
25 |
- [`mime_content_type`](https://www.php.net/manual/en/function.mime-content-type.php) *Requires fileinfo. (PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)*
|
26 |
|
30 |
|
31 |
## Installation
|
32 |
|
33 |
+
Install with composer:
|
34 |
+
```
|
35 |
+
composer require rosell-dk/image-mime-type-guesser
|
36 |
+
```
|
37 |
|
38 |
## Usage
|
39 |
|
102 |
- https://github.com/Intervention/mimesniffer
|
103 |
- https://github.com/zjsxwc/mime-type-sniffer
|
104 |
- https://github.com/Tinram/File-Identifier
|
105 |
+
|
106 |
+
## Do you like what I do?
|
107 |
+
Perhaps you want to support my work, so I can continue doing it :)
|
108 |
+
|
109 |
+
- [Become a backer or sponsor on Patreon](https://www.patreon.com/rosell).
|
110 |
+
- [Buy me a Coffee](https://ko-fi.com/rosell)
|
vendor/rosell-dk/image-mime-type-guesser/composer.json
CHANGED
@@ -8,19 +8,21 @@
|
|
8 |
"ci": [
|
9 |
"@test",
|
10 |
"@phpcs-all",
|
11 |
-
"@composer validate --no-check-all --strict"
|
|
|
12 |
],
|
13 |
"cs-fix-all": [
|
14 |
"php-cs-fixer fix src"
|
15 |
],
|
16 |
"cs-fix": "php-cs-fixer fix",
|
17 |
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
18 |
-
"test": "phpunit --coverage-text --coverage-clover=build/
|
19 |
"test-no-cov": "phpunit tests",
|
20 |
"test2": "phpunit tests",
|
21 |
-
"phpcs": "phpcs --standard=
|
22 |
-
"phpcs-all": "phpcs --standard=
|
23 |
-
"phpcbf": "phpcbf --standard=PSR2"
|
|
|
24 |
},
|
25 |
"extra": {
|
26 |
"scripts-descriptions": {
|
@@ -45,10 +47,15 @@
|
|
45 |
"role": "Project Author"
|
46 |
}
|
47 |
],
|
|
|
|
|
|
|
|
|
48 |
"require-dev": {
|
49 |
"friendsofphp/php-cs-fixer": "^2.11",
|
50 |
"phpunit/phpunit": "^9.3",
|
51 |
-
"squizlabs/php_codesniffer": "3.*"
|
|
|
52 |
},
|
53 |
"config": {
|
54 |
"sort-packages": true
|
8 |
"ci": [
|
9 |
"@test",
|
10 |
"@phpcs-all",
|
11 |
+
"@composer validate --no-check-all --strict",
|
12 |
+
"@phpstan"
|
13 |
],
|
14 |
"cs-fix-all": [
|
15 |
"php-cs-fixer fix src"
|
16 |
],
|
17 |
"cs-fix": "php-cs-fixer fix",
|
18 |
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
19 |
+
"test": "phpunit --coverage-text=build/coverage.txt --coverage-clover=build/coverage.clover --coverage-html=build/coverage --whitelist=src tests",
|
20 |
"test-no-cov": "phpunit tests",
|
21 |
"test2": "phpunit tests",
|
22 |
+
"phpcs": "phpcs --standard=phpcs-ruleset.xml",
|
23 |
+
"phpcs-all": "phpcs --standard=phpcs-ruleset.xml src",
|
24 |
+
"phpcbf": "phpcbf --standard=PSR2",
|
25 |
+
"phpstan": "vendor/bin/phpstan analyse src --level=4"
|
26 |
},
|
27 |
"extra": {
|
28 |
"scripts-descriptions": {
|
47 |
"role": "Project Author"
|
48 |
}
|
49 |
],
|
50 |
+
"require": {
|
51 |
+
"php": "^5.6 | ^7.0 | ^8.0",
|
52 |
+
"rosell-dk/image-mime-type-sniffer": "^1.0"
|
53 |
+
},
|
54 |
"require-dev": {
|
55 |
"friendsofphp/php-cs-fixer": "^2.11",
|
56 |
"phpunit/phpunit": "^9.3",
|
57 |
+
"squizlabs/php_codesniffer": "3.*",
|
58 |
+
"phpstan/phpstan": "^1.5"
|
59 |
},
|
60 |
"config": {
|
61 |
"sort-packages": true
|
vendor/rosell-dk/image-mime-type-guesser/phpcs-ruleset.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Custom Standard">
|
3 |
+
<description>PSR2 without line ending rule - let git manage the EOL cross the platforms</description>
|
4 |
+
<rule ref="PSR2" />
|
5 |
+
<rule ref="Generic.Files.LineEndings">
|
6 |
+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
|
7 |
+
</rule>
|
8 |
+
</ruleset>
|
vendor/rosell-dk/image-mime-type-guesser/phpstan.neon
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
parameters:
|
2 |
+
reportUnmatchedIgnoredErrors: false
|
3 |
+
ignoreErrors:
|
4 |
+
- '#Unsafe usage of new static#'
|
vendor/rosell-dk/image-mime-type-guesser/phpunit.xml.dist
CHANGED
@@ -19,10 +19,4 @@
|
|
19 |
<directory suffix=".php">src/</directory>
|
20 |
</whitelist>
|
21 |
</filter>
|
22 |
-
<logging>
|
23 |
-
<log type="junit" target="build/report.junit.xml"/>
|
24 |
-
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
25 |
-
<log type="coverage-text" target="build/coverage.txt"/>
|
26 |
-
<log type="coverage-html" target="build/coverage"/>
|
27 |
-
</logging>
|
28 |
</phpunit>
|
19 |
<directory suffix=".php">src/</directory>
|
20 |
</whitelist>
|
21 |
</filter>
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
</phpunit>
|
vendor/rosell-dk/image-mime-type-guesser/src/Detectors/AbstractDetector.php
CHANGED
@@ -24,7 +24,6 @@ abstract class AbstractDetector
|
|
24 |
/**
|
25 |
* Create an instance of this class
|
26 |
*
|
27 |
-
* @param string $filePath The path to the file
|
28 |
* @return static
|
29 |
*/
|
30 |
public static function createInstance()
|
24 |
/**
|
25 |
* Create an instance of this class
|
26 |
*
|
|
|
27 |
* @return static
|
28 |
*/
|
29 |
public static function createInstance()
|
vendor/rosell-dk/image-mime-type-guesser/src/Detectors/SignatureSniffer.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace ImageMimeTypeGuesser\Detectors;
|
4 |
+
|
5 |
+
use \ImageMimeTypeGuesser\Detectors\AbstractDetector;
|
6 |
+
use \ImageMimeTypeSniffer\ImageMimeTypeSniffer;
|
7 |
+
|
8 |
+
class SignatureSniffer extends AbstractDetector
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Try to detect mime type by sniffing the first four bytes.
|
13 |
+
*
|
14 |
+
* Returns:
|
15 |
+
* - mime type (string) (if it is in fact an image, and type could be determined)
|
16 |
+
* - false (if it is not an image type that the server knowns about)
|
17 |
+
* - null (if nothing can be determined)
|
18 |
+
*
|
19 |
+
* @param string $filePath The path to the file
|
20 |
+
* @return string|false|null mimetype (if it is an image, and type could be determined),
|
21 |
+
* false (if it is not an image type that the server knowns about)
|
22 |
+
* or null (if nothing can be determined)
|
23 |
+
*/
|
24 |
+
protected function doDetect($filePath)
|
25 |
+
{
|
26 |
+
return ImageMimeTypeSniffer::detect($filePath);
|
27 |
+
}
|
28 |
+
}
|
vendor/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php
CHANGED
@@ -20,8 +20,8 @@ class Stack extends AbstractDetector
|
|
20 |
protected function doDetect($filePath)
|
21 |
{
|
22 |
$detectors = [
|
|
|
23 |
'FInfo',
|
24 |
-
'SniffFirstFourBytes',
|
25 |
'ExifImageType',
|
26 |
//'GetImageSize', // Disabled, as documentation says it is unreliable
|
27 |
'MimeContentType',
|
20 |
protected function doDetect($filePath)
|
21 |
{
|
22 |
$detectors = [
|
23 |
+
'SignatureSniffer',
|
24 |
'FInfo',
|
|
|
25 |
'ExifImageType',
|
26 |
//'GetImageSize', // Disabled, as documentation says it is unreliable
|
27 |
'MimeContentType',
|
vendor/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php
CHANGED
@@ -24,7 +24,6 @@ class GuessFromExtension
|
|
24 |
*
|
25 |
* If no mapping found, nothing is returned
|
26 |
*
|
27 |
-
* TODO: jp2, jpx, ...
|
28 |
* Returns:
|
29 |
* - mimetype (if file extension could be mapped to an image type),
|
30 |
* - false (if file extension could be mapped to a type known not to be an image type)
|
@@ -52,39 +51,6 @@ class GuessFromExtension
|
|
52 |
$fileExtension = strtolower($fileExtension);
|
53 |
}*/
|
54 |
|
55 |
-
|
56 |
-
if ($result !== 1) {
|
57 |
-
return null;
|
58 |
-
}
|
59 |
-
$fileExtension = $matches[1];
|
60 |
-
|
61 |
-
// Trivial image mime types
|
62 |
-
if (in_array($fileExtension, ['apng', 'avif', 'bmp', 'gif', 'jpeg', 'png', 'tiff', 'webp'])) {
|
63 |
-
return 'image/' . $fileExtension;
|
64 |
-
}
|
65 |
-
|
66 |
-
// Common extensions that are definitely not images
|
67 |
-
if (in_array($fileExtension, ['txt', 'doc', 'zip', 'gz', 'exe'])) {
|
68 |
-
return false;
|
69 |
-
}
|
70 |
-
|
71 |
-
// Non-trivial image mime types
|
72 |
-
switch ($fileExtension) {
|
73 |
-
case 'ico':
|
74 |
-
case 'cur':
|
75 |
-
return 'image/x-icon'; // or perhaps 'vnd.microsoft.icon' ?
|
76 |
-
|
77 |
-
case 'jpg':
|
78 |
-
return 'image/jpeg';
|
79 |
-
|
80 |
-
case 'svg':
|
81 |
-
return 'image/svg+xml';
|
82 |
-
|
83 |
-
case 'tif':
|
84 |
-
return 'image/tiff';
|
85 |
-
}
|
86 |
-
|
87 |
-
// We do not know this extension, return null
|
88 |
-
return null;
|
89 |
}
|
90 |
}
|
24 |
*
|
25 |
* If no mapping found, nothing is returned
|
26 |
*
|
|
|
27 |
* Returns:
|
28 |
* - mimetype (if file extension could be mapped to an image type),
|
29 |
* - false (if file extension could be mapped to a type known not to be an image type)
|
51 |
$fileExtension = strtolower($fileExtension);
|
52 |
}*/
|
53 |
|
54 |
+
return MimeMap::filenameToMime($filePath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
}
|
vendor/rosell-dk/image-mime-type-guesser/src/MimeMap.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* ImageMimeTypeGuesser - Detect / guess mime type of an image
|
5 |
+
*
|
6 |
+
* @link https://github.com/rosell-dk/image-mime-type-guesser
|
7 |
+
* @license MIT
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace ImageMimeTypeGuesser;
|
11 |
+
|
12 |
+
class MimeMap
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Map image file extension to mime type
|
17 |
+
*
|
18 |
+
*
|
19 |
+
* @param string $filePath The filename (or path), ie "image.jpg"
|
20 |
+
* @return string|false|null mimetype (if file extension could be mapped to an image type),
|
21 |
+
* false (if file extension could be mapped to a type known not to be an image type)
|
22 |
+
* or null (if file extension could not be mapped to any mime type, using our little list)
|
23 |
+
*/
|
24 |
+
public static function filenameToMime($filePath)
|
25 |
+
{
|
26 |
+
$result = preg_match('#\\.([^.]*)$#', $filePath, $matches);
|
27 |
+
if ($result !== 1) {
|
28 |
+
return null;
|
29 |
+
}
|
30 |
+
$fileExtension = $matches[1];
|
31 |
+
return self::extToMime($fileExtension);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Map image file extension to mime type
|
36 |
+
*
|
37 |
+
*
|
38 |
+
* @param string $fileExtension The file extension (ie "jpg")
|
39 |
+
* @return string|false|null mimetype (if file extension could be mapped to an image type),
|
40 |
+
* false (if file extension could be mapped to a type known not to be an image type)
|
41 |
+
* or null (if file extension could not be mapped to any mime type, using our little list)
|
42 |
+
*/
|
43 |
+
public static function extToMime($fileExtension)
|
44 |
+
{
|
45 |
+
|
46 |
+
$fileExtension = strtolower($fileExtension);
|
47 |
+
|
48 |
+
// Trivial image mime types
|
49 |
+
if (in_array($fileExtension, ['apng', 'avif', 'bmp', 'gif', 'jpeg', 'png', 'tiff', 'webp'])) {
|
50 |
+
return 'image/' . $fileExtension;
|
51 |
+
}
|
52 |
+
|
53 |
+
// Common extensions that are definitely not images
|
54 |
+
if (in_array($fileExtension, ['txt', 'doc', 'zip', 'gz', 'exe'])) {
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
// Non-trivial image mime types
|
59 |
+
switch ($fileExtension) {
|
60 |
+
case 'ico':
|
61 |
+
case 'cur':
|
62 |
+
return 'image/x-icon'; // or perhaps 'vnd.microsoft.icon' ?
|
63 |
+
|
64 |
+
case 'jpg':
|
65 |
+
return 'image/jpeg';
|
66 |
+
|
67 |
+
case 'svg':
|
68 |
+
return 'image/svg+xml';
|
69 |
+
|
70 |
+
case 'tif':
|
71 |
+
return 'image/tiff';
|
72 |
+
}
|
73 |
+
|
74 |
+
// We do not know this extension, return null
|
75 |
+
return null;
|
76 |
+
}
|
77 |
+
}
|
vendor/rosell-dk/image-mime-type-sniffer/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2018 Bjørn Rosell
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6 |
+
|
7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8 |
+
|
9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
vendor/rosell-dk/image-mime-type-sniffer/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Image Mime Type Sniffer
|
2 |
+
|
3 |
+
[![Latest Stable Version](https://img.shields.io/packagist/v/rosell-dk/image-mime-type-sniffer.svg)](https://packagist.org/packages/rosell-dk/image-mime-type-sniffer)
|
4 |
+
[![Minimum PHP Version](https://img.shields.io/packagist/php-v/rosell-dk/image-mime-type-sniffer)](https://php.net)
|
5 |
+
[![Build Status](https://github.com/rosell-dk/image-mime-type-sniffer/actions/workflows/php.yml/badge.svg)](https://github.com/rosell-dk/image-mime-type-sniffer/actions/workflows/php.yml)
|
6 |
+
[![Software License](https://img.shields.io/badge/license-MIT-418677.svg)](https://github.com/rosell-dk/image-mime-type-sniffer/blob/master/LICENSE)
|
7 |
+
[![Coverage](https://img.shields.io/endpoint?url=https://little-b.it/image-mime-type-sniffer/code-coverage/coverage-badge.json)](http://little-b.it/image-mime-type-sniffer/code-coverage/coverage/index.html)
|
8 |
+
[![Monthly Downloads](http://poser.pugx.org/rosell-dk/image-mime-type-sniffer/d/monthly)](https://packagist.org/packages/rosell-dk/image-mime-type-sniffer)
|
9 |
+
[![Dependents](http://poser.pugx.org/rosell-dk/image-mime-type-sniffer/dependents)](https://packagist.org/packages/rosell-dk/image-mime-type-sniffer/dependents?order_by=downloads)
|
10 |
+
|
11 |
+
|
12 |
+
Gets mime type of common *image* files by sniffing the file content, looking for signatures.
|
13 |
+
|
14 |
+
The fact that this library limits its ambition to sniff images makes it light and simple. It is also quite fast. Most other sniffers iterates through all common signatures, however this library uses a mix of finite-state machine approach and iteration to achieve a good balance of speed, compactness, simplicity and readability.
|
15 |
+
|
16 |
+
The library recognizes the most widespread image formats, such as GIF, JPEG, WEBP, AVIF, JPEG-2000 and HEIC.
|
17 |
+
|
18 |
+
# Usage
|
19 |
+
|
20 |
+
```php
|
21 |
+
use \ImageMimeTypeSniffer\ImageMimeTypeSniffer;
|
22 |
+
|
23 |
+
$mimeType = ImageMimeTypeSniffer::detect($fileName);
|
24 |
+
if (is_null($mimeType)) {
|
25 |
+
// mimetype was not detected, which means the file is probably not an image (unless it is a rare type)
|
26 |
+
} else {
|
27 |
+
// It is an image, and we know the mimeType
|
28 |
+
}
|
29 |
+
```
|
30 |
+
|
31 |
+
PS: An `\Exception` is thrown if the file is unreadable.
|
32 |
+
|
33 |
+
# List of recognized image types:
|
34 |
+
|
35 |
+
- application/psd
|
36 |
+
- image/avif
|
37 |
+
- image/bmp
|
38 |
+
- image/gif
|
39 |
+
- image/heic
|
40 |
+
- image/jp2
|
41 |
+
- image/jp20
|
42 |
+
- image/jpeg
|
43 |
+
- image/jpm
|
44 |
+
- image/jpx
|
45 |
+
- image/png
|
46 |
+
- image/svg+xml
|
47 |
+
- image/tiff
|
48 |
+
- image/webp
|
49 |
+
- image/x-icon
|
50 |
+
- video/mj2
|
51 |
+
|
52 |
+
TODO: image/heif
|
53 |
+
|
54 |
+
|
55 |
+
# Alternatives
|
56 |
+
|
57 |
+
I have created a library that uses this library as well as other methods (*finfo*, *exif_imagetype*, etc) for determining image type. You might want to use that instead, to cover all bases. It is available here: [image-mime-type-guesser](https://github.com/rosell-dk/image-mime-type-guesser).
|
58 |
+
|
59 |
+
There are also other PHP mime type sniffers out there:
|
60 |
+
|
61 |
+
- https://github.com/Intervention/mimesniffer
|
62 |
+
- https://github.com/Tinram/File-Identifier
|
63 |
+
- https://github.com/shanept/MimeSniffer
|
64 |
+
- https://github.com/zjsxwc/mime-type-sniffer
|
65 |
+
- https://github.com/thephpleague/mime-type-detection/tree/main/src
|
vendor/rosell-dk/image-mime-type-sniffer/composer.json
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "rosell-dk/image-mime-type-sniffer",
|
3 |
+
"description": "Sniff mime type (images only)",
|
4 |
+
"type": "library",
|
5 |
+
"license": "MIT",
|
6 |
+
"keywords": ["mime", "mime type", "image", "images"],
|
7 |
+
"scripts": {
|
8 |
+
"ci": [
|
9 |
+
"@test",
|
10 |
+
"@phpcs-all",
|
11 |
+
"@composer validate --no-check-all --strict",
|
12 |
+
"@phpstan"
|
13 |
+
],
|
14 |
+
"cs-fix-all": [
|
15 |
+
"php-cs-fixer fix src"
|
16 |
+
],
|
17 |
+
"cs-fix": "php-cs-fixer fix",
|
18 |
+
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
19 |
+
"test": "phpunit --coverage-text=build/coverage.txt --coverage-clover=build/coverage.clover --coverage-html=build/coverage --whitelist=src tests",
|
20 |
+
"test-no-cov": "phpunit --no-coverage tests",
|
21 |
+
"test2": "phpunit tests",
|
22 |
+
"phpcs": "phpcs --standard=phpcs-ruleset.xml",
|
23 |
+
"phpcs-all": "phpcs --standard=phpcs-ruleset.xml src",
|
24 |
+
"phpcbf": "phpcbf --standard=PSR2",
|
25 |
+
"phpstan": "vendor/bin/phpstan analyse src --level=4"
|
26 |
+
},
|
27 |
+
"extra": {
|
28 |
+
"scripts-descriptions": {
|
29 |
+
"ci": "Run tests before CI",
|
30 |
+
"phpcs": "Checks coding styles (PSR2) of file/dir, which you must supply. To check all, supply 'src'",
|
31 |
+
"phpcbf": "Fix coding styles (PSR2) of file/dir, which you must supply. To fix all, supply 'src'",
|
32 |
+
"cs-fix-all": "Fix the coding style of all the source files, to comply with the PSR-2 coding standard",
|
33 |
+
"cs-fix": "Fix the coding style of a PHP file or directory, which you must specify.",
|
34 |
+
"test": "Launches the preconfigured PHPUnit"
|
35 |
+
}
|
36 |
+
},
|
37 |
+
"autoload": {
|
38 |
+
"psr-4": { "ImageMimeTypeSniffer\\": "src/" }
|
39 |
+
},
|
40 |
+
"autoload-dev": {
|
41 |
+
"psr-4": { "ImageMimeTypeSniffer\\Tests\\": "tests/" }
|
42 |
+
},
|
43 |
+
"authors": [
|
44 |
+
{
|
45 |
+
"name": "Bjørn Rosell",
|
46 |
+
"homepage": "https://www.bitwise-it.dk/contact",
|
47 |
+
"role": "Project Author"
|
48 |
+
}
|
49 |
+
],
|
50 |
+
"require": {
|
51 |
+
"php": ">=5.4"
|
52 |
+
},
|
53 |
+
"require-dev": {
|
54 |
+
"friendsofphp/php-cs-fixer": "^2.11",
|
55 |
+
"phpunit/phpunit": "^9.3",
|
56 |
+
"squizlabs/php_codesniffer": "3.*",
|
57 |
+
"phpstan/phpstan": "^1.5",
|
58 |
+
"mikey179/vfsstream": "^1.6"
|
59 |
+
},
|
60 |
+
"config": {
|
61 |
+
"sort-packages": true
|
62 |
+
}
|
63 |
+
}
|
vendor/rosell-dk/image-mime-type-sniffer/phpcs-ruleset.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Custom Standard">
|
3 |
+
<description>PSR2 without line ending rule - let git manage the EOL cross the platforms</description>
|
4 |
+
<rule ref="PSR2" />
|
5 |
+
<rule ref="Generic.Files.LineEndings">
|
6 |
+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
|
7 |
+
</rule>
|
8 |
+
</ruleset>
|
vendor/rosell-dk/image-mime-type-sniffer/phpunit.xml.dist
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="false" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php">
|
3 |
+
<testsuites>
|
4 |
+
<testsuite name="Test Suite">
|
5 |
+
<directory>./tests/</directory>
|
6 |
+
</testsuite>
|
7 |
+
</testsuites>
|
8 |
+
</phpunit>
|
vendor/rosell-dk/{image-mime-type-guesser/src/Detectors/SniffFirstFourBytes.php → image-mime-type-sniffer/src/ImageMimeTypeSniffer.php}
RENAMED
@@ -1,36 +1,70 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
class SniffFirstFourBytes extends AbstractDetector
|
8 |
{
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
-
* Try to detect mime type by sniffing the
|
12 |
*
|
13 |
* Returns:
|
14 |
* - mime type (string) (if it is in fact an image, and type could be determined)
|
15 |
-
* - false (if it is not an image type that the server knowns about)
|
16 |
* - null (if nothing can be determined)
|
17 |
*
|
18 |
* @param string $filePath The path to the file
|
19 |
-
* @return string|
|
20 |
-
*
|
21 |
-
*
|
22 |
*/
|
23 |
-
|
24 |
{
|
|
|
|
|
|
|
25 |
$handle = @fopen($filePath, 'r');
|
26 |
if ($handle === false) {
|
27 |
-
|
28 |
}
|
29 |
// 20 bytes is sufficient for all our sniffers, except image/svg+xml.
|
30 |
// The svg sniffer takes care of reading more
|
31 |
$sampleBin = @fread($handle, 20);
|
32 |
if ($sampleBin === false) {
|
33 |
-
|
|
|
|
|
|
|
34 |
}
|
35 |
$firstByte = $sampleBin[0];
|
36 |
$sampleHex = strtoupper(bin2hex($sampleBin));
|
@@ -38,11 +72,24 @@ class SniffFirstFourBytes extends AbstractDetector
|
|
38 |
$hexPatterns = [];
|
39 |
$binPatterns = [];
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
// https://www.rapidtables.com/convert/number/hex-to-ascii.html
|
42 |
switch ($firstByte) {
|
43 |
case "\x00":
|
44 |
$hexPatterns[] = ['image/x-icon', "/^00000(1?2)00/"];
|
45 |
|
|
|
|
|
46 |
if (preg_match("/^.{8}6A502020/", $sampleHex) === 1) {
|
47 |
// jpeg-2000 - a bit more complex, as block size may vary
|
48 |
// https://www.file-recovery.com/jp2-signature-format.htm
|
@@ -54,6 +101,8 @@ class SniffFirstFourBytes extends AbstractDetector
|
|
54 |
}
|
55 |
if (substr($sampleBin, $block1Size + 4, 4) == 'ftyp') {
|
56 |
$subtyp = substr($sampleBin, $block1Size + 8, 4);
|
|
|
|
|
57 |
if ($subtyp == 'mjp2') {
|
58 |
return 'video/mj2';
|
59 |
} else {
|
@@ -97,13 +146,6 @@ class SniffFirstFourBytes extends AbstractDetector
|
|
97 |
$binPatterns[] = ['image/svg+xml', "/^(<\?xml[^>]*\?>.*)?<svg/is"];
|
98 |
break;
|
99 |
|
100 |
-
case "f":
|
101 |
-
//$hexPatterns[] = ['image/heic', "/667479706865(6963|6978|7663|696D|6973|766D|7673)/"];
|
102 |
-
//$hexPatterns[] = ['image/heif', "/667479706D(69|73)6631)/"];
|
103 |
-
$binPatterns[] = ['image/heic', "/ftyphe(ic|ix|vc|im|is|vm|vs)/"];
|
104 |
-
$binPatterns[] = ['image/heif', "/ftypm(i|s)f1/"];
|
105 |
-
break;
|
106 |
-
|
107 |
case "\x89":
|
108 |
$hexPatterns[] = ['image/png', "/^89504E470D0A1A0A/"];
|
109 |
break;
|
@@ -131,14 +173,5 @@ class SniffFirstFourBytes extends AbstractDetector
|
|
131 |
http://phil.lavin.me.uk/2011/12/php-accurately-detecting-the-type-of-a-file/
|
132 |
|
133 |
*/
|
134 |
-
// TODO: JPEG 2000
|
135 |
-
// mime types: image/jp2, image/jpf, image/jpx, image/jpm
|
136 |
-
// http://fileformats.archiveteam.org/wiki/JPEG_2000
|
137 |
-
// https://www.file-recovery.com/jp2-signature-format.htm
|
138 |
-
/*
|
139 |
-
From: https://github.com/Tinram/File-Identifier/blob/master/src/FileSignatures.php
|
140 |
-
'JPG 2000' => '00 00 00 0c 6a 50 20 20 0d 0a 87 0a',
|
141 |
-
https://filesignatures.net/index.php?page=search&search=JP2&mode=EXT
|
142 |
-
*/
|
143 |
}
|
144 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace ImageMimeTypeSniffer;
|
4 |
|
5 |
+
class ImageMimeTypeSniffer
|
|
|
|
|
6 |
{
|
7 |
|
8 |
+
private static function checkFilePathIsRegularFile($input)
|
9 |
+
{
|
10 |
+
if (gettype($input) !== 'string') {
|
11 |
+
throw new \Exception('File path must be string');
|
12 |
+
}
|
13 |
+
if (strpos($input, chr(0)) !== false) {
|
14 |
+
throw new \Exception('NUL character is not allowed in file path!');
|
15 |
+
}
|
16 |
+
if (preg_match('#[\x{0}-\x{1f}]#', $input)) {
|
17 |
+
// prevents line feed, new line, tab, charater return, tab, ets.
|
18 |
+
throw new \Exception('Control characters #0-#20 not allowed in file path!');
|
19 |
+
}
|
20 |
+
// Prevent phar stream wrappers (security threat)
|
21 |
+
if (preg_match('#^phar://#', $input)) {
|
22 |
+
throw new \Exception('phar stream wrappers are not allowed in file path');
|
23 |
+
}
|
24 |
+
if (preg_match('#^(php|glob)://#', $input)) {
|
25 |
+
throw new \Exception('php and glob stream wrappers are not allowed in file path');
|
26 |
+
}
|
27 |
+
if (empty($input)) {
|
28 |
+
throw new \Exception('File path is empty!');
|
29 |
+
}
|
30 |
+
if (!@file_exists($input)) {
|
31 |
+
throw new \Exception('File does not exist');
|
32 |
+
}
|
33 |
+
if (@is_dir($input)) {
|
34 |
+
throw new \Exception('Expected a regular file, not a dir');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
/**
|
40 |
+
* Try to detect mime type by sniffing the signature
|
41 |
*
|
42 |
* Returns:
|
43 |
* - mime type (string) (if it is in fact an image, and type could be determined)
|
|
|
44 |
* - null (if nothing can be determined)
|
45 |
*
|
46 |
* @param string $filePath The path to the file
|
47 |
+
* @return string|null mimetype (if it is an image, and type could be determined),
|
48 |
+
* or null (if the file does not match any of the signatures tested)
|
49 |
+
* @throws \Exception if file cannot be opened/read
|
50 |
*/
|
51 |
+
public static function detect($filePath)
|
52 |
{
|
53 |
+
self::checkFilePathIsRegularFile($filePath);
|
54 |
+
|
55 |
+
|
56 |
$handle = @fopen($filePath, 'r');
|
57 |
if ($handle === false) {
|
58 |
+
throw new \Exception('File could not be opened');
|
59 |
}
|
60 |
// 20 bytes is sufficient for all our sniffers, except image/svg+xml.
|
61 |
// The svg sniffer takes care of reading more
|
62 |
$sampleBin = @fread($handle, 20);
|
63 |
if ($sampleBin === false) {
|
64 |
+
throw new \Exception('File could not be read');
|
65 |
+
}
|
66 |
+
if (strlen($sampleBin) < 20) {
|
67 |
+
return null; // File is too small for us to deal with
|
68 |
}
|
69 |
$firstByte = $sampleBin[0];
|
70 |
$sampleHex = strtoupper(bin2hex($sampleBin));
|
72 |
$hexPatterns = [];
|
73 |
$binPatterns = [];
|
74 |
|
75 |
+
//$hexPatterns[] = ['image/heic', "/667479706865(6963|6978|7663|696D|6973|766D|7673)/"];
|
76 |
+
//$hexPatterns[] = ['image/heif', "/667479706D(69|73)6631)/"];
|
77 |
+
// heic:
|
78 |
+
|
79 |
+
// HEIC signature: https://github.com/strukturag/libheif/issues/83#issuecomment-421427091
|
80 |
+
// https://nokiatech.github.io/heif/technical.html
|
81 |
+
// https://perkeep.org/internal/magic/magic.go
|
82 |
+
// https://www.file-recovery.com/mp4-signature-format.htm
|
83 |
+
$binPatterns[] = ['image/heic', "/^(.{4}|.{8})ftyphe(ic|ix|vc|im|is|vm|vs)/"];
|
84 |
+
//$binPatterns[] = ['image/heif', "/^(.{4}|.{8})ftypm(i|s)f1/"];
|
85 |
+
|
86 |
// https://www.rapidtables.com/convert/number/hex-to-ascii.html
|
87 |
switch ($firstByte) {
|
88 |
case "\x00":
|
89 |
$hexPatterns[] = ['image/x-icon', "/^00000(1?2)00/"];
|
90 |
|
91 |
+
$binPatterns[] = ['image/avif', "/^(.{4}|.{8})ftypavif/"];
|
92 |
+
|
93 |
if (preg_match("/^.{8}6A502020/", $sampleHex) === 1) {
|
94 |
// jpeg-2000 - a bit more complex, as block size may vary
|
95 |
// https://www.file-recovery.com/jp2-signature-format.htm
|
101 |
}
|
102 |
if (substr($sampleBin, $block1Size + 4, 4) == 'ftyp') {
|
103 |
$subtyp = substr($sampleBin, $block1Size + 8, 4);
|
104 |
+
// "jp2 " (.JP2), "jp20" (.JPA), "jpm " (.JPM), "jpx " (.JPX).
|
105 |
+
|
106 |
if ($subtyp == 'mjp2') {
|
107 |
return 'video/mj2';
|
108 |
} else {
|
146 |
$binPatterns[] = ['image/svg+xml', "/^(<\?xml[^>]*\?>.*)?<svg/is"];
|
147 |
break;
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
case "\x89":
|
150 |
$hexPatterns[] = ['image/png', "/^89504E470D0A1A0A/"];
|
151 |
break;
|
173 |
http://phil.lavin.me.uk/2011/12/php-accurately-detecting-the-type-of-a-file/
|
174 |
|
175 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
}
|
vendor/rosell-dk/locate-binaries/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2018 Bjørn Rosell
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6 |
+
|
7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8 |
+
|
9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
vendor/rosell-dk/locate-binaries/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Locate Binaries
|
2 |
+
|
3 |
+
[![Build Status](https://github.com/rosell-dk/locate-binaries/workflows/build/badge.svg)](https://github.com/rosell-dk/locate-binaries/actions/workflows/php.yml)
|
4 |
+
[![Coverage](https://img.shields.io/endpoint?url=https://little-b.it/locate-binaries/code-coverage/coverage-badge.json)](http://little-b.it/locate-binaries/code-coverage/coverage/index.html)
|
5 |
+
[![Software License](https://img.shields.io/badge/license-MIT-418677.svg)](https://github.com/rosell-dk/locate-binary/blob/master/LICENSE)
|
6 |
+
[![Latest Stable Version](https://img.shields.io/packagist/v/rosell-dk/locate-binaries.svg)](https://packagist.org/packages/rosell-dk/locate-binaries)
|
7 |
+
[![Minimum PHP Version](https://img.shields.io/packagist/php-v/rosell-dk/locate-binaries)](https://php.net)
|
8 |
+
|
9 |
+
Just a little class for locating binaries.
|
10 |
+
You need `exec()`, `shell_exec()` or similar enabled for it to work. Otherwise, it will throw.
|
11 |
+
|
12 |
+
Works on Linux, Windows and Mac.
|
13 |
+
|
14 |
+
## Usage
|
15 |
+
|
16 |
+
To locate installed `cwebp` binaries (found on Linux with `which -a`, falling back to `whereis -b`; on Windows found using `where`):
|
17 |
+
```
|
18 |
+
$cwebBinariesFound = LocateBinaries::locateInstalledBinaries('cwebp');
|
19 |
+
```
|
20 |
+
Note that you get an array of matches - there may be several versions of a binary on a system.
|
21 |
+
|
22 |
+
The library also adds another method for locating binaries by peeking in common system paths, such as *usr/bin* and `C:\Windows\System32`
|
23 |
+
However, beware that these dirs could be subject to open_basedir restrictions which can lead to warning entries in the error log. The other method is therefore best.
|
24 |
+
|
25 |
+
Well warned, here it is the alternative, which you in some cases might want to fall back to after trying the first.
|
26 |
+
```
|
27 |
+
$imagickBinariesFound = LocateBinaries::locateInCommonSystemPaths('convert');
|
28 |
+
```
|
29 |
+
|
30 |
+
## Notes
|
31 |
+
The library uses the [exec-with-fallback](https://github.com/rosell-dk/exec-with-fallback) library in order to be able to use alternatives to exec() when exec() is disabled.
|
32 |
+
|
33 |
+
## Do you like what I do?
|
34 |
+
Perhaps you want to support my work, so I can continue doing it :)
|
35 |
+
|
36 |
+
- [Become a backer or sponsor on Patreon](https://www.patreon.com/rosell).
|
37 |
+
- [Buy me a Coffee](https://ko-fi.com/rosell)
|
38 |
+
|
39 |
+
Thanks!
|
vendor/rosell-dk/locate-binaries/composer.json
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "rosell-dk/locate-binaries",
|
3 |
+
"description": "Locate a binaries by means of exec() or similar",
|
4 |
+
"type": "library",
|
5 |
+
"license": "MIT",
|
6 |
+
"keywords": ["locate", "binary", "whereis", "which", "discover"],
|
7 |
+
"scripts": {
|
8 |
+
"ci": [
|
9 |
+
"@test",
|
10 |
+
"@phpcs-all",
|
11 |
+
"@composer validate --no-check-all --strict",
|
12 |
+
"@phpstan"
|
13 |
+
],
|
14 |
+
"phpunit": "phpunit --coverage-text",
|
15 |
+
"test": "phpunit --coverage-text=build/coverage.txt --coverage-clover=build/coverage.clover --coverage-html=build/coverage --whitelist=src tests",
|
16 |
+
"test-no-cov": "phpunit --no-coverage tests",
|
17 |
+
"test-41": "phpunit --no-coverage --configuration 'phpunit-41.xml.dist'",
|
18 |
+
"test-with-coverage": "phpunit --coverage-text --configuration 'phpunit-with-coverage.xml.dist'",
|
19 |
+
"test-41-with-coverage": "phpunit --coverage-text --configuration 'phpunit-41.xml.dist'",
|
20 |
+
"cs-fix-all": [
|
21 |
+
"php-cs-fixer fix src"
|
22 |
+
],
|
23 |
+
"cs-fix": "php-cs-fixer fix",
|
24 |
+
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
25 |
+
"phpcs": "phpcs --standard=phpcs-ruleset.xml",
|
26 |
+
"phpcs-all": "phpcs --standard=phpcs-ruleset.xml src",
|
27 |
+
"phpcbf": "phpcbf --standard=PSR2",
|
28 |
+
"phpstan": "vendor/bin/phpstan analyse src --level=4",
|
29 |
+
"phpstan-global-old": "~/.composer/vendor/bin/phpstan analyse src --level=4",
|
30 |
+
"phpstan-global": "~/.config/composer/vendor/bin/phpstan analyse src --level=4"
|
31 |
+
},
|
32 |
+
"extra": {
|
33 |
+
"scripts-descriptions": {
|
34 |
+
"ci": "Run tests before CI",
|
35 |
+
"phpcs": "Checks coding styles (PSR2) of file/dir, which you must supply. To check all, supply 'src'",
|
36 |
+
"phpcbf": "Fix coding styles (PSR2) of file/dir, which you must supply. To fix all, supply 'src'",
|
37 |
+
"cs-fix-all": "Fix the coding style of all the source files, to comply with the PSR-2 coding standard",
|
38 |
+
"cs-fix": "Fix the coding style of a PHP file or directory, which you must specify.",
|
39 |
+
"test": "Launches the preconfigured PHPUnit"
|
40 |
+
}
|
41 |
+
},
|
42 |
+
"autoload": {
|
43 |
+
"psr-4": { "LocateBinaries\\": "src/" }
|
44 |
+
},
|
45 |
+
"autoload-dev": {
|
46 |
+
"psr-4": { "LocateBinaries\\Tests\\": "tests/" }
|
47 |
+
},
|
48 |
+
"authors": [
|
49 |
+
{
|
50 |
+
"name": "Bjørn Rosell",
|
51 |
+
"homepage": "https://www.bitwise-it.dk/contact",
|
52 |
+
"role": "Project Author"
|
53 |
+
}
|
54 |
+
],
|
55 |
+
"require": {
|
56 |
+
"php": ">=5.6",
|
57 |
+
"rosell-dk/exec-with-fallback": "^1.0.0",
|
58 |
+
"rosell-dk/file-util": "^0.1.0"
|
59 |
+
},
|
60 |
+
"require-dev": {
|
61 |
+
"friendsofphp/php-cs-fixer": "^2.11",
|
62 |
+
"phpunit/phpunit": "^9.3",
|
63 |
+
"squizlabs/php_codesniffer": "3.*",
|
64 |
+
"phpstan/phpstan": "^1.5"
|
65 |
+
},
|
66 |
+
"config": {
|
67 |
+
"sort-packages": true
|
68 |
+
}
|
69 |
+
}
|
vendor/rosell-dk/locate-binaries/phpcs-ruleset.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Custom Standard">
|
3 |
+
<description>PSR2 without line ending rule - let git manage the EOL cross the platforms</description>
|
4 |
+
<rule ref="PSR2" />
|
5 |
+
<rule ref="Generic.Files.LineEndings">
|
6 |
+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
|
7 |
+
</rule>
|
8 |
+
</ruleset>
|
vendor/rosell-dk/locate-binaries/src/LocateBinaries.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace LocateBinaries;
|
4 |
+
|
5 |
+
use FileUtil\FileExists;
|
6 |
+
use ExecWithFallback\ExecWithFallback;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Locate path (or multiple paths) of a binary
|
10 |
+
*
|
11 |
+
* @package LocateBinaries
|
12 |
+
* @author Bjørn Rosell <it@rosell.dk>
|
13 |
+
*/
|
14 |
+
class LocateBinaries
|
15 |
+
{
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Locate binaries by looking in common system paths.
|
19 |
+
*
|
20 |
+
* We try a small set of common system paths, such as "/usr/bin".
|
21 |
+
* On Windows, we only try C:\Windows\System32
|
22 |
+
* Note that you do not have to add ".exe" file extension on Windows, it is taken care of
|
23 |
+
*
|
24 |
+
* @param string $binary the binary to look for (ie "cwebp")
|
25 |
+
*
|
26 |
+
* @return array binaries found in common system locations
|
27 |
+
*/
|
28 |
+
public static function locateInCommonSystemPaths($binary)
|
29 |
+
{
|
30 |
+
$binaries = [];
|
31 |
+
|
32 |
+
$commonSystemPaths = [];
|
33 |
+
|
34 |
+
if (stripos(PHP_OS, 'WIN') === 0) {
|
35 |
+
$commonSystemPaths = [
|
36 |
+
'C:\Windows\System32',
|
37 |
+
];
|
38 |
+
$binary .= '.exe';
|
39 |
+
} else {
|
40 |
+
$commonSystemPaths = [
|
41 |
+
'/usr/bin',
|
42 |
+
'/usr/local/bin',
|
43 |
+
'/usr/gnu/bin',
|
44 |
+
'/usr/syno/bin',
|
45 |
+
'/bin',
|
46 |
+
];
|
47 |
+
}
|
48 |
+
|
49 |
+
foreach ($commonSystemPaths as $dir) {
|
50 |
+
// PS: FileExists might throw if exec() or similar is unavailable. We let it.
|
51 |
+
// - this class assumes exec is available
|
52 |
+
if (FileExists::fileExistsTryHarder($dir . DIRECTORY_SEPARATOR . $binary)) {
|
53 |
+
$binaries[] = $dir . DIRECTORY_SEPARATOR . $binary;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
return $binaries;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Locate installed binaries using ie "whereis -b cwebp" (for Linux, Mac, etc)
|
61 |
+
*
|
62 |
+
* @return array Array of paths locateed (possibly empty)
|
63 |
+
*/
|
64 |
+
private static function locateBinariesUsingWhereIs($binary)
|
65 |
+
{
|
66 |
+
$isMac = (PHP_OS == 'Darwin');
|
67 |
+
$command = 'whereis ' . ($isMac ? '' : '-b ') . $binary . ' 2>&1';
|
68 |
+
|
69 |
+
ExecWithFallback::exec($command, $output, $returnCode);
|
70 |
+
//echo 'command:' . $command;
|
71 |
+
//echo 'output:' . print_r($output, true);
|
72 |
+
|
73 |
+
if (($returnCode == 0) && (isset($output[0]))) {
|
74 |
+
// On linux, result looks like this:
|
75 |
+
// "cwebp: /usr/bin/cwebp /usr/local/bin/cwebp"
|
76 |
+
// or, for empty: "cwebp:"
|
77 |
+
|
78 |
+
if ($output[0] == ($binary . ':')) {
|
79 |
+
return [];
|
80 |
+
}
|
81 |
+
|
82 |
+
// On mac, it is not prepended with name of binary.
|
83 |
+
// I don't know if mac returns one result per line or is space seperated
|
84 |
+
// As I don't know if some systems might return several lines,
|
85 |
+
// I assume that some do and convert to space-separation:
|
86 |
+
$result = implode(' ', $output);
|
87 |
+
|
88 |
+
// Next, lets remove the prepended binary (if exists)
|
89 |
+
$result = preg_replace('#\b' . $binary . ':\s?#', '', $result);
|
90 |
+
|
91 |
+
// And back to array
|
92 |
+
return explode(' ', $result);
|
93 |
+
}
|
94 |
+
return [];
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* locate installed binaries using "which -a cwebp"
|
99 |
+
*
|
100 |
+
* @param string $binary the binary to look for (ie "cwebp")
|
101 |
+
*
|
102 |
+
* @return array Array of paths locateed (possibly empty)
|
103 |
+
*/
|
104 |
+
private static function locateBinariesUsingWhich($binary)
|
105 |
+
{
|
106 |
+
// As suggested by @cantoute here:
|
107 |
+
// https://wordpress.org/support/topic/sh-1-usr-local-bin-cwebp-not-found/
|
108 |
+
ExecWithFallback::exec('which -a ' . $binary . ' 2>&1', $output, $returnCode);
|
109 |
+
if ($returnCode == 0) {
|
110 |
+
return $output;
|
111 |
+
}
|
112 |
+
return [];
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Locate binaries using where.exe (for Windows)
|
117 |
+
*
|
118 |
+
* @param string $binary the binary to look for (ie "cwebp")
|
119 |
+
*
|
120 |
+
* @return array binaries found
|
121 |
+
*/
|
122 |
+
private static function locateBinariesUsingWhere($binary)
|
123 |
+
{
|
124 |
+
ExecWithFallback::exec('where.exe ' . $binary . ' 2>&1', $output, $returnCode);
|
125 |
+
if ($returnCode == 0) {
|
126 |
+
return $output;
|
127 |
+
}
|
128 |
+
return [];
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Locate installed binaries
|
133 |
+
*
|
134 |
+
* For linuk, we use "which -a" or, if that fails "whereis -b"
|
135 |
+
* For Windows, we use "where.exe"
|
136 |
+
* These commands only searces within $PATH. So it only finds installed binaries (which is good,
|
137 |
+
* as it would be unsafe to deal with binaries found scattered around)
|
138 |
+
*
|
139 |
+
* @param string $binary the binary to look for (ie "cwebp")
|
140 |
+
*
|
141 |
+
* @return array binaries found
|
142 |
+
*/
|
143 |
+
public static function locateInstalledBinaries($binary)
|
144 |
+
{
|
145 |
+
if (stripos(PHP_OS, 'WIN') === 0) {
|
146 |
+
$paths = self::locateBinariesUsingWhere($binary);
|
147 |
+
if (count($paths) > 0) {
|
148 |
+
return $paths;
|
149 |
+
}
|
150 |
+
} else {
|
151 |
+
$paths = self::locateBinariesUsingWhich($binary);
|
152 |
+
if (count($paths) > 0) {
|
153 |
+
return $paths;
|
154 |
+
}
|
155 |
+
|
156 |
+
$paths = self::locateBinariesUsingWhereIs($binary);
|
157 |
+
if (count($paths) > 0) {
|
158 |
+
return $paths;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
return [];
|
162 |
+
}
|
163 |
+
}
|
vendor/rosell-dk/webp-convert/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
[![Latest Stable Version](https://img.shields.io/packagist/v/rosell-dk/webp-convert.svg)](https://packagist.org/packages/rosell-dk/webp-convert)
|
4 |
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)](https://php.net)
|
5 |
[![Build Status](https://img.shields.io/github/workflow/status/rosell-dk/webp-convert/PHP?logo=GitHub)](https://github.com/rosell-dk/webp-convert/actions/workflows/php.yml)
|
|
|
6 |
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/rosell-dk/webp-convert/blob/master/LICENSE)
|
7 |
[![Monthly Downloads](http://poser.pugx.org/rosell-dk/webp-convert/d/monthly)](https://packagist.org/packages/rosell-dk/webp-convert)
|
8 |
[![Dependents](http://poser.pugx.org/rosell-dk/webp-convert/dependents)](https://packagist.org/packages/rosell-dk/webp-convert/dependents?order_by=downloads)
|
3 |
[![Latest Stable Version](https://img.shields.io/packagist/v/rosell-dk/webp-convert.svg)](https://packagist.org/packages/rosell-dk/webp-convert)
|
4 |
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)](https://php.net)
|
5 |
[![Build Status](https://img.shields.io/github/workflow/status/rosell-dk/webp-convert/PHP?logo=GitHub)](https://github.com/rosell-dk/webp-convert/actions/workflows/php.yml)
|
6 |
+
[![Coverage](https://img.shields.io/endpoint?url=https://little-b.it/webp-convert/code-coverage/coverage-badge.json)](http://little-b.it/webp-convert/code-coverage/coverage/index.html)
|
7 |
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/rosell-dk/webp-convert/blob/master/LICENSE)
|
8 |
[![Monthly Downloads](http://poser.pugx.org/rosell-dk/webp-convert/d/monthly)](https://packagist.org/packages/rosell-dk/webp-convert)
|
9 |
[![Dependents](http://poser.pugx.org/rosell-dk/webp-convert/dependents)](https://packagist.org/packages/rosell-dk/webp-convert/dependents?order_by=downloads)
|
vendor/rosell-dk/webp-convert/composer.json
CHANGED
@@ -12,17 +12,18 @@
|
|
12 |
"@phpstan-global"
|
13 |
],
|
14 |
"phpunit": "phpunit --coverage-text",
|
15 |
-
"test": "phpunit --
|
16 |
"test-41": "phpunit --no-coverage --configuration 'phpunit-41.xml.dist'",
|
17 |
"test-with-coverage": "phpunit --coverage-text --configuration 'phpunit-with-coverage.xml.dist'",
|
18 |
"test-41-with-coverage": "phpunit --coverage-text --configuration 'phpunit-41.xml.dist'",
|
|
|
19 |
"cs-fix-all": [
|
20 |
"php-cs-fixer fix src"
|
21 |
],
|
22 |
"cs-fix": "php-cs-fixer fix",
|
23 |
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
24 |
-
"phpcs": "phpcs --standard=
|
25 |
-
"phpcs-all": "phpcs --standard=
|
26 |
"phpcbf": "phpcbf --standard=PSR2",
|
27 |
"phpstan": "vendor/bin/phpstan analyse src --level=4",
|
28 |
"phpstan-global-old": "~/.composer/vendor/bin/phpstan analyse src --level=4",
|
@@ -59,7 +60,8 @@
|
|
59 |
"require": {
|
60 |
"php": "^5.6 | ^7.0 | ^8.0",
|
61 |
"rosell-dk/exec-with-fallback": "^1.0.0",
|
62 |
-
"rosell-dk/image-mime-type-guesser": "^
|
|
|
63 |
},
|
64 |
"suggest": {
|
65 |
"ext-gd": "to use GD extension for converting. Note: Gd must be compiled with webp support",
|
@@ -70,7 +72,8 @@
|
|
70 |
"require-dev": {
|
71 |
"friendsofphp/php-cs-fixer": "^2.11",
|
72 |
"phpunit/phpunit": "^9.3",
|
73 |
-
"squizlabs/php_codesniffer": "3.*"
|
|
|
74 |
},
|
75 |
"config": {
|
76 |
"sort-packages": true
|
12 |
"@phpstan-global"
|
13 |
],
|
14 |
"phpunit": "phpunit --coverage-text",
|
15 |
+
"test": "phpunit --coverage-text=build/coverage.txt --coverage-clover=build/coverage.clover --coverage-html=build/coverage --whitelist=src tests",
|
16 |
"test-41": "phpunit --no-coverage --configuration 'phpunit-41.xml.dist'",
|
17 |
"test-with-coverage": "phpunit --coverage-text --configuration 'phpunit-with-coverage.xml.dist'",
|
18 |
"test-41-with-coverage": "phpunit --coverage-text --configuration 'phpunit-41.xml.dist'",
|
19 |
+
"test-no-cov": "phpunit --no-coverage tests",
|
20 |
"cs-fix-all": [
|
21 |
"php-cs-fixer fix src"
|
22 |
],
|
23 |
"cs-fix": "php-cs-fixer fix",
|
24 |
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
25 |
+
"phpcs": "phpcs --standard=phpcs-ruleset.xml",
|
26 |
+
"phpcs-all": "phpcs --standard=phpcs-ruleset.xml src",
|
27 |
"phpcbf": "phpcbf --standard=PSR2",
|
28 |
"phpstan": "vendor/bin/phpstan analyse src --level=4",
|
29 |
"phpstan-global-old": "~/.composer/vendor/bin/phpstan analyse src --level=4",
|
60 |
"require": {
|
61 |
"php": "^5.6 | ^7.0 | ^8.0",
|
62 |
"rosell-dk/exec-with-fallback": "^1.0.0",
|
63 |
+
"rosell-dk/image-mime-type-guesser": "^1.1.1",
|
64 |
+
"rosell-dk/locate-binaries": "^1.0"
|
65 |
},
|
66 |
"suggest": {
|
67 |
"ext-gd": "to use GD extension for converting. Note: Gd must be compiled with webp support",
|
72 |
"require-dev": {
|
73 |
"friendsofphp/php-cs-fixer": "^2.11",
|
74 |
"phpunit/phpunit": "^9.3",
|
75 |
+
"squizlabs/php_codesniffer": "3.*",
|
76 |
+
"phpstan/phpstan": "^1.5"
|
77 |
},
|
78 |
"config": {
|
79 |
"sort-packages": true
|
vendor/rosell-dk/webp-convert/phpcs-ruleset.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="Custom Standard">
|
3 |
+
<description>PSR2 without line ending rule - let git manage the EOL cross the platforms</description>
|
4 |
+
<rule ref="PSR2" />
|
5 |
+
<rule ref="Generic.Files.LineEndings">
|
6 |
+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
|
7 |
+
</rule>
|
8 |
+
</ruleset>
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/LoggerTrait.php
CHANGED
@@ -15,7 +15,7 @@ namespace WebPConvert\Convert\Converters\BaseTraits;
|
|
15 |
trait LoggerTrait
|
16 |
{
|
17 |
|
18 |
-
/** @var \WebPConvert\Loggers\BaseLogger The logger (or null if not set) */
|
19 |
protected $logger;
|
20 |
|
21 |
/**
|
15 |
trait LoggerTrait
|
16 |
{
|
17 |
|
18 |
+
/** @var \WebPConvert\Loggers\BaseLogger|null The logger (or null if not set) */
|
19 |
protected $logger;
|
20 |
|
21 |
/**
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php
CHANGED
@@ -2,6 +2,9 @@
|
|
2 |
|
3 |
namespace WebPConvert\Convert\Converters;
|
4 |
|
|
|
|
|
|
|
5 |
use WebPConvert\Convert\Converters\AbstractConverter;
|
6 |
use WebPConvert\Convert\Converters\BaseTraits\WarningLoggerTrait;
|
7 |
use WebPConvert\Convert\Converters\ConverterTraits\EncodingAutoTrait;
|
@@ -9,9 +12,7 @@ use WebPConvert\Convert\Converters\ConverterTraits\ExecTrait;
|
|
9 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperational\SystemRequirementsNotMetException;
|
10 |
use WebPConvert\Convert\Exceptions\ConversionFailedException;
|
11 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperationalException;
|
12 |
-
use WebPConvert\Helpers\BinaryDiscovery;
|
13 |
use WebPConvert\Options\OptionFactory;
|
14 |
-
use ExecWithFallback\ExecWithFallback;
|
15 |
|
16 |
/**
|
17 |
* Convert images to webp by calling cwebp binary.
|
@@ -746,7 +747,7 @@ class Cwebp extends AbstractConverter
|
|
746 |
$startTime = self::startTimer();
|
747 |
$this->logDiscoverAction('try-discovering-cwebp', 'using "which -a cwebp" command.');
|
748 |
if ($this->options['try-discovering-cwebp']) {
|
749 |
-
$moreBinaries =
|
750 |
$this->logBinariesFound($moreBinaries, $startTime);
|
751 |
$binaries = array_merge($binaries, $moreBinaries);
|
752 |
}
|
@@ -755,7 +756,7 @@ class Cwebp extends AbstractConverter
|
|
755 |
$startTime = self::startTimer();
|
756 |
$this->logDiscoverAction('try-common-system-paths', 'by peeking in common system paths');
|
757 |
if ($this->options['try-common-system-paths']) {
|
758 |
-
$moreBinaries =
|
759 |
$this->logBinariesFound($moreBinaries, $startTime);
|
760 |
$binaries = array_merge($binaries, $moreBinaries);
|
761 |
}
|
2 |
|
3 |
namespace WebPConvert\Convert\Converters;
|
4 |
|
5 |
+
use ExecWithFallback\ExecWithFallback;
|
6 |
+
use LocateBinaries\LocateBinaries;
|
7 |
+
|
8 |
use WebPConvert\Convert\Converters\AbstractConverter;
|
9 |
use WebPConvert\Convert\Converters\BaseTraits\WarningLoggerTrait;
|
10 |
use WebPConvert\Convert\Converters\ConverterTraits\EncodingAutoTrait;
|
12 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperational\SystemRequirementsNotMetException;
|
13 |
use WebPConvert\Convert\Exceptions\ConversionFailedException;
|
14 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperationalException;
|
|
|
15 |
use WebPConvert\Options\OptionFactory;
|
|
|
16 |
|
17 |
/**
|
18 |
* Convert images to webp by calling cwebp binary.
|
747 |
$startTime = self::startTimer();
|
748 |
$this->logDiscoverAction('try-discovering-cwebp', 'using "which -a cwebp" command.');
|
749 |
if ($this->options['try-discovering-cwebp']) {
|
750 |
+
$moreBinaries = LocateBinaries::locateInstalledBinaries('cwebp');
|
751 |
$this->logBinariesFound($moreBinaries, $startTime);
|
752 |
$binaries = array_merge($binaries, $moreBinaries);
|
753 |
}
|
756 |
$startTime = self::startTimer();
|
757 |
$this->logDiscoverAction('try-common-system-paths', 'by peeking in common system paths');
|
758 |
if ($this->options['try-common-system-paths']) {
|
759 |
+
$moreBinaries = LocateBinaries::locateInCommonSystemPaths('cwebp');
|
760 |
$this->logBinariesFound($moreBinaries, $startTime);
|
761 |
$binaries = array_merge($binaries, $moreBinaries);
|
762 |
}
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php
CHANGED
@@ -25,7 +25,7 @@ class Ewww extends AbstractConverter
|
|
25 |
use CloudConverterTrait;
|
26 |
use CurlTrait;
|
27 |
|
28 |
-
/** @var array Array of invalid or exceeded api keys discovered during conversions (during the request) */
|
29 |
public static $nonFunctionalApiKeysDiscoveredDuringConversion;
|
30 |
|
31 |
public function getUniqueOptions($imageType)
|
@@ -346,7 +346,11 @@ class Ewww extends AbstractConverter
|
|
346 |
if ($responseObj->error == 'invalid') {
|
347 |
return 'invalid';
|
348 |
} else {
|
349 |
-
|
|
|
|
|
|
|
|
|
350 |
}
|
351 |
}
|
352 |
if (!isset($responseObj->status)) {
|
25 |
use CloudConverterTrait;
|
26 |
use CurlTrait;
|
27 |
|
28 |
+
/** @var array|null Array of invalid or exceeded api keys discovered during conversions (during the request) */
|
29 |
public static $nonFunctionalApiKeysDiscoveredDuringConversion;
|
30 |
|
31 |
public function getUniqueOptions($imageType)
|
346 |
if ($responseObj->error == 'invalid') {
|
347 |
return 'invalid';
|
348 |
} else {
|
349 |
+
if ($responseObj->error == 'bye invalid') {
|
350 |
+
return 'invalid';
|
351 |
+
} else {
|
352 |
+
throw new \Exception('Ewww returned unexpected error: ' . $response);
|
353 |
+
}
|
354 |
}
|
355 |
}
|
356 |
if (!isset($responseObj->status)) {
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/Gd.php
CHANGED
@@ -241,7 +241,7 @@ class Gd extends AbstractConverter
|
|
241 |
if (function_exists('imageistruecolor')) {
|
242 |
if (imageistruecolor($image)) {
|
243 |
$this->logLn('image is true color');
|
244 |
-
|
245 |
} else {
|
246 |
$this->logLn('image is not true color');
|
247 |
$mustMakeTrueColor = true;
|
@@ -354,7 +354,7 @@ class Gd extends AbstractConverter
|
|
354 |
// and - sorry - was to lazy to find out right now. So for now: better safe than sorry. #320
|
355 |
$error = null;
|
356 |
$success = false;
|
357 |
-
|
358 |
try {
|
359 |
// Beware: This call can throw FATAL on windows (cannot be catched)
|
360 |
// This for example happens on palette images
|
241 |
if (function_exists('imageistruecolor')) {
|
242 |
if (imageistruecolor($image)) {
|
243 |
$this->logLn('image is true color');
|
244 |
+
$whatIsItNow = true;
|
245 |
} else {
|
246 |
$this->logLn('image is not true color');
|
247 |
$mustMakeTrueColor = true;
|
354 |
// and - sorry - was to lazy to find out right now. So for now: better safe than sorry. #320
|
355 |
$error = null;
|
356 |
$success = false;
|
357 |
+
|
358 |
try {
|
359 |
// Beware: This call can throw FATAL on windows (cannot be catched)
|
360 |
// This for example happens on palette images
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/ImageMagick.php
CHANGED
@@ -2,14 +2,15 @@
|
|
2 |
|
3 |
namespace WebPConvert\Convert\Converters;
|
4 |
|
|
|
|
|
|
|
5 |
use WebPConvert\Convert\Converters\AbstractConverter;
|
6 |
use WebPConvert\Convert\Converters\ConverterTraits\ExecTrait;
|
7 |
use WebPConvert\Convert\Converters\ConverterTraits\EncodingAutoTrait;
|
8 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperational\SystemRequirementsNotMetException;
|
9 |
use WebPConvert\Convert\Exceptions\ConversionFailedException;
|
10 |
-
use WebPConvert\Helpers\BinaryDiscovery;
|
11 |
use WebPConvert\Options\OptionFactory;
|
12 |
-
use ExecWithFallback\ExecWithFallback;
|
13 |
|
14 |
//use WebPConvert\Convert\Exceptions\ConversionFailed\InvalidInput\TargetNotFoundException;
|
15 |
|
@@ -69,7 +70,7 @@ class ImageMagick extends AbstractConverter
|
|
69 |
}
|
70 |
|
71 |
if ($this->options['try-common-system-paths']) {
|
72 |
-
$binaries =
|
73 |
if (!empty($binaries)) {
|
74 |
return $binaries[0];
|
75 |
}
|
2 |
|
3 |
namespace WebPConvert\Convert\Converters;
|
4 |
|
5 |
+
use ExecWithFallback\ExecWithFallback;
|
6 |
+
use LocateBinaries\LocateBinaries;
|
7 |
+
|
8 |
use WebPConvert\Convert\Converters\AbstractConverter;
|
9 |
use WebPConvert\Convert\Converters\ConverterTraits\ExecTrait;
|
10 |
use WebPConvert\Convert\Converters\ConverterTraits\EncodingAutoTrait;
|
11 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperational\SystemRequirementsNotMetException;
|
12 |
use WebPConvert\Convert\Exceptions\ConversionFailedException;
|
|
|
13 |
use WebPConvert\Options\OptionFactory;
|
|
|
14 |
|
15 |
//use WebPConvert\Convert\Exceptions\ConversionFailed\InvalidInput\TargetNotFoundException;
|
16 |
|
70 |
}
|
71 |
|
72 |
if ($this->options['try-common-system-paths']) {
|
73 |
+
$binaries = LocateBinaries::locateInCommonSystemPaths('convert');
|
74 |
if (!empty($binaries)) {
|
75 |
return $binaries[0];
|
76 |
}
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/Stack.php
CHANGED
@@ -8,10 +8,6 @@ use WebPConvert\Convert\Exceptions\ConversionFailedException;
|
|
8 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperationalException;
|
9 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperational\SystemRequirementsNotMetException;
|
10 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConversionSkippedException;
|
11 |
-
use WebPConvert\Options\BooleanOption;
|
12 |
-
use WebPConvert\Options\ArrayOption;
|
13 |
-
use WebPConvert\Options\GhostOption;
|
14 |
-
use WebPConvert\Options\SensitiveArrayOption;
|
15 |
use WebPConvert\Options\OptionFactory;
|
16 |
|
17 |
//use WebPConvert\Convert\Exceptions\ConversionFailed\InvalidInput\TargetNotFoundException;
|
8 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperationalException;
|
9 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperational\SystemRequirementsNotMetException;
|
10 |
use WebPConvert\Convert\Exceptions\ConversionFailed\ConversionSkippedException;
|
|
|
|
|
|
|
|
|
11 |
use WebPConvert\Options\OptionFactory;
|
12 |
|
13 |
//use WebPConvert\Convert\Exceptions\ConversionFailed\InvalidInput\TargetNotFoundException;
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/Vips.php
CHANGED
@@ -77,9 +77,9 @@ class Vips extends AbstractConverter
|
|
77 |
}
|
78 |
|
79 |
|
80 |
-
|
81 |
-
$result =
|
82 |
-
if ($result
|
83 |
$message = vips_error_buffer();
|
84 |
if (strpos($message, 'VipsOperation: class "webpsave" not found') === 0) {
|
85 |
throw new SystemRequirementsNotMetException(
|
@@ -208,9 +208,9 @@ class Vips extends AbstractConverter
|
|
208 |
}
|
209 |
|
210 |
/**
|
211 |
-
*
|
212 |
*
|
213 |
-
* Tries to
|
214 |
* Vips fails when a parameter is not supported, but we detect this and unset that parameter and try again
|
215 |
* (recursively call itself until there is no more of these kind of errors).
|
216 |
*
|
@@ -279,11 +279,11 @@ class Vips extends AbstractConverter
|
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
-
* Convert
|
283 |
*
|
284 |
* Tries to create image resource and save it as webp using the calculated options.
|
285 |
-
* Vips fails when a parameter is not supported, but
|
286 |
-
* (repeat until success).
|
287 |
*
|
288 |
* @throws ConversionFailedException if conversion fails.
|
289 |
*/
|
77 |
}
|
78 |
|
79 |
|
80 |
+
vips_error_buffer(); // clear error buffer
|
81 |
+
$result = vips_call('webpsave', null);
|
82 |
+
if ($result === -1) {
|
83 |
$message = vips_error_buffer();
|
84 |
if (strpos($message, 'VipsOperation: class "webpsave" not found') === 0) {
|
85 |
throw new SystemRequirementsNotMetException(
|
208 |
}
|
209 |
|
210 |
/**
|
211 |
+
* Save as webp, using vips extension.
|
212 |
*
|
213 |
+
* Tries to save image resource as webp, using the supplied options.
|
214 |
* Vips fails when a parameter is not supported, but we detect this and unset that parameter and try again
|
215 |
* (recursively call itself until there is no more of these kind of errors).
|
216 |
*
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
+
* Convert, using vips extension.
|
283 |
*
|
284 |
* Tries to create image resource and save it as webp using the calculated options.
|
285 |
+
* PS: The Vips "webpsave" call fails when a parameter is not supported, but our webpsave() method
|
286 |
+
* detect this and unset that parameter and try again (repeat until success).
|
287 |
*
|
288 |
* @throws ConversionFailedException if conversion fails.
|
289 |
*/
|
vendor/rosell-dk/webp-convert/src/Helpers/BinaryDiscovery.php
DELETED
@@ -1,109 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WebPConvert\Helpers;
|
4 |
-
|
5 |
-
use WebPConvert\Helpers\FileExists;
|
6 |
-
use ExecWithFallback\ExecWithFallback;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Discover multiple paths of a binary
|
10 |
-
*
|
11 |
-
* @package WebPConvert
|
12 |
-
* @author Bjørn Rosell <it@rosell.dk>
|
13 |
-
* @since Class available since Release 2.3.0
|
14 |
-
*/
|
15 |
-
class BinaryDiscovery
|
16 |
-
{
|
17 |
-
|
18 |
-
// Common system paths
|
19 |
-
private static $commonSystemPaths = [
|
20 |
-
'/usr/bin',
|
21 |
-
'/usr/local/bin',
|
22 |
-
'/usr/gnu/bin',
|
23 |
-
'/usr/syno/bin',
|
24 |
-
'/bin',
|
25 |
-
];
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Discover binaries by looking in common system paths.
|
29 |
-
*
|
30 |
-
* We try a small set of common system paths, such as "/usr/bin".
|
31 |
-
*
|
32 |
-
* @param string $binary the binary to look for (ie "cwebp")
|
33 |
-
*
|
34 |
-
* @return array binaries found in common system locations
|
35 |
-
*/
|
36 |
-
public static function discoverInCommonSystemPaths($binary)
|
37 |
-
{
|
38 |
-
$binaries = [];
|
39 |
-
foreach (self::$commonSystemPaths as $dir) {
|
40 |
-
// PS: FileExists might throw if exec() or similar is unavailable. We let it.
|
41 |
-
// - this class assumes exec is available
|
42 |
-
if (FileExists::fileExistsTryHarder($dir . '/' . $binary)) {
|
43 |
-
$binaries[] = $dir . '/' . $binary;
|
44 |
-
}
|
45 |
-
}
|
46 |
-
return $binaries;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Discover installed binaries using ie "whereis -b cwebp"
|
51 |
-
*
|
52 |
-
* @return array Array of cwebp paths discovered (possibly empty)
|
53 |
-
*/
|
54 |
-
private static function discoverBinariesUsingWhereIs($binary)
|
55 |
-
{
|
56 |
-
// This method was added due to #226.
|
57 |
-
ExecWithFallback::exec('whereis -b ' . $binary . ' 2>&1', $output, $returnCode);
|
58 |
-
if (($returnCode == 0) && (isset($output[0]))) {
|
59 |
-
$result = $output[0];
|
60 |
-
// Ie: "cwebp: /usr/bin/cwebp /usr/local/bin/cwebp"
|
61 |
-
if (preg_match('#^' . $binary . ':\s(.*)$#', $result, $matches)) {
|
62 |
-
return explode(' ', $matches[1]);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
return [];
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Discover installed binaries using "which -a cwebp"
|
70 |
-
*
|
71 |
-
* @param string $binary the binary to look for (ie "cwebp")
|
72 |
-
*
|
73 |
-
* @return array Array of paths discovered (possibly empty)
|
74 |
-
*/
|
75 |
-
private static function discoverBinariesUsingWhich($binary)
|
76 |
-
{
|
77 |
-
// As suggested by @cantoute here:
|
78 |
-
// https://wordpress.org/support/topic/sh-1-usr-local-bin-cwebp-not-found/
|
79 |
-
ExecWithFallback::exec('which -a ' . $binary . ' 2>&1', $output, $returnCode);
|
80 |
-
if ($returnCode == 0) {
|
81 |
-
return $output;
|
82 |
-
}
|
83 |
-
return [];
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Discover binaries using "which -a" or, if that fails "whereis -b"
|
88 |
-
*
|
89 |
-
* These commands only searces within $PATH. So it only finds installed binaries (which is good,
|
90 |
-
* as it would be unsafe to deal with binaries found scattered around)
|
91 |
-
*
|
92 |
-
* @param string $binary the binary to look for (ie "cwebp")
|
93 |
-
*
|
94 |
-
* @return array binaries found in common system locations
|
95 |
-
*/
|
96 |
-
public static function discoverInstalledBinaries($binary)
|
97 |
-
{
|
98 |
-
$paths = self::discoverBinariesUsingWhich($binary);
|
99 |
-
if (count($paths) > 0) {
|
100 |
-
return $paths;
|
101 |
-
}
|
102 |
-
|
103 |
-
$paths = self::discoverBinariesUsingWhereIs($binary);
|
104 |
-
if (count($paths) > 0) {
|
105 |
-
return $paths;
|
106 |
-
}
|
107 |
-
return [];
|
108 |
-
}
|
109 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/rosell-dk/webp-convert/src/Options/Option.php
CHANGED
@@ -44,7 +44,7 @@ class Option
|
|
44 |
/** @var array UI Def */
|
45 |
protected $ui;
|
46 |
|
47 |
-
/** @var array Extra Schema Def (ie holding 'title', 'description' or other)*/
|
48 |
protected $extraSchemaDefs;
|
49 |
|
50 |
|
44 |
/** @var array UI Def */
|
45 |
protected $ui;
|
46 |
|
47 |
+
/** @var array|null Extra Schema Def (ie holding 'title', 'description' or other)*/
|
48 |
protected $extraSchemaDefs;
|
49 |
|
50 |
|
vendor/rosell-dk/webp-convert/src/Serve/ServeConvertedWebP.php
CHANGED
@@ -4,6 +4,7 @@ namespace WebPConvert\Serve;
|
|
4 |
use WebPConvert\Convert\Exceptions\ConversionFailedException;
|
5 |
use WebPConvert\Helpers\InputValidator;
|
6 |
use WebPConvert\Helpers\MimeType;
|
|
|
7 |
use WebPConvert\Serve\Exceptions\ServeFailedException;
|
8 |
use WebPConvert\Serve\Header;
|
9 |
use WebPConvert\Serve\Report;
|
@@ -72,7 +73,14 @@ class ServeConvertedWebP
|
|
72 |
*/
|
73 |
public static function serveOriginal($source, $serveImageOptions = [])
|
74 |
{
|
75 |
-
InputValidator::checkSource($source)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
$contentType = MimeType::getMimeTypeDetectionResult($source);
|
77 |
if (is_null($contentType)) {
|
78 |
throw new ServeFailedException('Rejecting to serve original (mime type cannot be determined)');
|
4 |
use WebPConvert\Convert\Exceptions\ConversionFailedException;
|
5 |
use WebPConvert\Helpers\InputValidator;
|
6 |
use WebPConvert\Helpers\MimeType;
|
7 |
+
use WebPConvert\Helpers\PathChecker;
|
8 |
use WebPConvert\Serve\Exceptions\ServeFailedException;
|
9 |
use WebPConvert\Serve\Header;
|
10 |
use WebPConvert\Serve\Report;
|
73 |
*/
|
74 |
public static function serveOriginal($source, $serveImageOptions = [])
|
75 |
{
|
76 |
+
// PS: We do not use InputValidator::checkSource($source) because we want to be
|
77 |
+
// a bit more lenient here and allow any image to be served (even though ie webp does not
|
78 |
+
// qualify for being used as a source when converting)
|
79 |
+
|
80 |
+
// Check that the filename is ok (no control chars, streamwrappers), and that the file exists
|
81 |
+
// and is not a dir
|
82 |
+
PathChecker::checkSourcePath($source);
|
83 |
+
|
84 |
$contentType = MimeType::getMimeTypeDetectionResult($source);
|
85 |
if (is_null($contentType)) {
|
86 |
throw new ServeFailedException('Rejecting to serve original (mime type cannot be determined)');
|
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.25.
|
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.25.5
|
7 |
* Author: Bjørn Rosell
|
8 |
* Author URI: https://www.bitwise-it.dk
|
9 |
* License: GPL2
|