Skip to content

Commit

Permalink
#164 fix fatal error and notices when processing invalid images
Browse files Browse the repository at this point in the history
  • Loading branch information
tbela99 committed Apr 7, 2022
1 parent 02b1535 commit 58c2562
Show file tree
Hide file tree
Showing 162 changed files with 620 additions and 741 deletions.
2 changes: 1 addition & 1 deletion gzip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<license>Released under dual license LGPL v3 | MIT</license>
<authorEmail>contact@tbela.net</authorEmail>
<authorUrl>https://tbela.net</authorUrl>
<version>3.0</version>
<version>3.0.1</version>
<description>PLG_SYSTEM_GZIP_XML_DESCRIPTION</description>
<files>
<folder>docs</folder>
Expand Down
2 changes: 0 additions & 2 deletions helpers/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ public function preProcessHTML(array $options, $html)

if (!empty($replace)) {

$search = '</head>';

if (preg_match('#(<meta\s*charset=[^>]+>)#', $html, $match)) {

return str_replace($match[1], $match[1] . $replace, $html);
Expand Down
2 changes: 2 additions & 0 deletions helpers/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ public static function convert($file, array $options = [])

if ($img) {

imagepalettetotruecolor($img);

if (AVIF) {

imageavif($img, $newFile);
Expand Down
10 changes: 9 additions & 1 deletion lib/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ public function load ($file) {
}

$image_info = getimagesize($file);
$this->_abspath = $file;


if($image_info === false) {

throw new Exception(sprintf('unsupported image format: %s', $file), 400);
}


$this->_abspath = $file;
$this->_image_type = $image_info[2];

if($this->_image_type == IMAGETYPE_JPEG) {
Expand Down
135 changes: 0 additions & 135 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,135 +0,0 @@
(function () {
'use strict';

// @ts-check
/**
* Rollup transform settings
* @package GZip Plugin
* @copyright Copyright (C) 2005 - 2018 Thierry Bela.
*
* dual licensed
*
* @license LGPL v3
* @license MIT License
*/

const libReady = {
input: "js/lib/lib.ready.js",
output: {
name: "LIB",
file: "js/dist/lib.ready.js",
format: "iife"
}
};

const libImages = {
input: "js/lib/index.images.js",
output: {
name: "LIB",
file: "js/dist/lib.images.js",
format: "iife"
}
};

const critical = {
input: "./worker/src/critical/critical.js",
output: {

name: 'critical',
file:"./worker/dist/critical.js",
format: "iife"
}
};

const criticalExtract = {
input: "./worker/src/critical/extract.js",
output: {

file:"./worker/dist/critical-extract.js",
format: "iife"
}
};

const serviceworker = {
input: "worker/src/index.js",
output: {
file: "worker/dist/serviceworker.js",
format: "iife"
}
};

const oneSignal = {
input: "./worker/src/onesignal/onesignal.js",
output: {
file: "./worker/dist/onesignal.js",
format: "iife"
}
};

const serviceworkerAdmin = {
input: "worker/src/administrator/index.js",
output: {
file: "worker/dist/serviceworker.administrator.js",
format: "iife"
}
};

const browserPrefetch = {
input: "worker/src/prefetch/prefetch.js",
output: {
name: "prefetch",
file: "worker/dist/browser.prefetch.js",
format: "iife"
}
};

const sync = {
input: "worker/src/sync/sw.sync.fallback.js",
output: {
file: "worker/dist/sync.fallback.js",
format: "iife"
}
};

var config = /*#__PURE__*/Object.freeze({
__proto__: null,
libReady: libReady,
libImages: libImages,
critical: critical,
criticalExtract: criticalExtract,
serviceworker: serviceworker,
oneSignal: oneSignal,
serviceworkerAdmin: serviceworkerAdmin,
browserPrefetch: browserPrefetch,
sync: sync
});

// @ts-check

const rollup = require("rollup");

for (let name in config) {
(async function (config, name) {
try {
// create a bundle
console.log('build ' + name.replace(/[A-Z]/g, function (all) { return '.' + all.toLocaleLowerCase()}) + '.js' + ' ...');

const bundle = await rollup.rollup(config);

// generate code
await bundle.generate(config.output);

// or write the bundle to disk
await bundle.write(config.output);
} catch (error) {
console.log({
name,
error
});

throw error;
}
})(config[name], name);
}

}());
Loading

0 comments on commit 58c2562

Please sign in to comment.