From afbcadf33cebe8678322c1a8d0c4be4e794d4cb3 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Mon, 7 Mar 2016 16:45:01 -0500 Subject: [PATCH 1/6] Begin prep for 2.3 release --- .gitignore | 2 ++ HISTORY.txt | 34 ++++++++++++++++++++++------------ docs/CookBook.wiki.md | 7 +++---- docs/CustomSource.wiki.md | 2 +- min/lib/DooDigestAuth.php | 2 ++ min/lib/FirePHP.php | 2 ++ min/lib/JSMinPlus.php | 6 +++++- min/lib/Minify/Loader.php | 5 +++++ min/lib/Minify/Logger.php | 2 +- 9 files changed, 43 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 3d403b4..42733c5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,7 @@ # / /test /.idea/ +/composer.lock .DS_Store /vendor +/.php_cs.cache diff --git a/HISTORY.txt b/HISTORY.txt index 464251c..39b46e4 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,10 +1,20 @@ Minify Release History -(master) - * Builder styled with Bootstrap (thanks to help from acidvertigo) - * Add config option for simply concatenating files +Version 2.3.0 + * Adds `$min_concatOnly` option to just concatenate files + * Deprecates use of Minify_Loader + * Deprecates use of Minify_Logger + * Deprecates use of JSMinPlus + * Deprecates use of FirePHP + * Deprecates use of DooDigestAuth -Version 2.2.0 +Version 2.2.1 (2014-10-30) + * Builder styled with Bootstrap (thanks to help from acidvertigo) + * Update CSSmin to v.2.4.8 + * Added WinCache + * URLs with spaces properly rewritten + +Version 2.2.0 (2014-03-12) * Fix handling of RegEx in certain situations in JSMin * Thanks to Vovan-VE for reporting this * Update composer.json with support info @@ -26,11 +36,11 @@ Version 2.2.0 * Allow far-future expiration and file versioning with the "v" querystirng parameter in addition to existing method * Lots of general code tidy ups -Version 2.1.7 +Version 2.1.7 (2013-07-23) * Fixes arbitrary file inclusion vulnerability on some systems * Thanks to Matt Mecham for reporting this -Version 2.1.6 +Version 2.1.6 (2013-07-19) * JSMin fixes * Prevents some Closure Compiler API failures * Uses autoloading for all class loading @@ -42,7 +52,7 @@ Version 2.1.6 * CLI script more portable * Adds composer.json -Version 2.1.5 +Version 2.1.5 (2012-03-10) * Removed XSS vulnerability * Disabled builder bby default * command line tools to minify and rewrite URIs in CSS @@ -51,7 +61,7 @@ Version 2.1.5 * Closure Compiler uses cURL when allow_url_fopen is off * Missing file notices when using groups -Version 2.1.4 +Version 2.1.4 (2010-07-10) * Option to minify JS with Closure Compiler API w/ JSMin failover * Cookie/bookmarklet-based debug mode. No HTML editing! * Allows 1 file to be missing w/o complete failure @@ -67,7 +77,7 @@ Version 2.1.4 * Removed annoying maxFiles limit * mbstring.func_overload usage is safer -Version 2.1.3 +Version 2.1.3 (2009-06-30) * HTTP fixes * ETag generation now valid (different when gzipped) * Vary header always sent when Accept-Encoding is sniffed @@ -79,7 +89,7 @@ Version 2.1.3 * Allow setting contentType in Minify_Source objects * No more 5.3 deprecation warnings: split() removed -Version 2.1.2 +Version 2.1.2 (2009-03-04) * Javascript fixes * Debug mode no longer confused by "*/*" in strings/RegExps (jQuery) * quote characters inside RegExp literals no longer cause exception @@ -91,14 +101,14 @@ Version 2.1.2 * Builder app doesn't fail on systems without gzdeflate() * APC caching class included -Version 2.1.1 +Version 2.1.1 (2008-10-19) * Bug fix release * Detection and workarounds for zlib.output_compression and non-PHP encoding modules * Zlib not required (mod_rewrite, et.al., can still be used for encoding) * HTML : More IE conditional comments preserved * Minify_groupUri() utility fixed -Version 2.1.0 +Version 2.1.0 (2008-09-18) * "min" default application for quick deployment * Minify URI Builder app & bookmarklet for quickly creating minify URIs * Relative URIs in CSS file are fixed automatically by default diff --git a/docs/CookBook.wiki.md b/docs/CookBook.wiki.md index a68de4d..975ddfc 100644 --- a/docs/CookBook.wiki.md +++ b/docs/CookBook.wiki.md @@ -91,13 +91,12 @@ $min_serveOptions['minifiers']['text/css'] = array('Minify_CSSmin', 'minify'); ## JSMin+ -Minify 2.1.3 comes with Tino Zijdel's [JSMin+](http://crisp.tweakblogs.net/blog/1665/a-new-javascript-minifier-jsmin+.html) 1.1. This is a full parser based on a port of [Narcissus](http://en.wikipedia.org/wiki/Narcissus_(JavaScript_engine)). To try it out: +Tino Zijdel's [JSMin+](http://crisp.tweakblogs.net/blog/6861/jsmin%2B-version-14.html) has resulted in memory usage problems for many users and will be removed from the Minify codebase in 3.0. If you wish to use it, you should download it outside the Minify directory and link to it: + ``` +require '/path/to/jsminplus.php'; $min_serveOptions['minifiers']['application/x-javascript'] = array('JSMinPlus', 'minify'); ``` -This should yield smaller javascript files, but I've tested this only briefly. For production you may want to get the [latest version](http://crisp.tweakblogs.net/blog/cat/716) (you must rename it: `min/lib/JSMinPlus.php`). - -Note: JSMin+ is memory intensive, so be prepared to up your memory limit. Also it has no [comment preservation](http://code.google.com/p/minify/source/browse/tags/release_2.1.3/min/lib/JSMin.php#10) as of 1.3, in case you rely on this. ## Server-specific Options diff --git a/docs/CustomSource.wiki.md b/docs/CustomSource.wiki.md index 1d615cb..c593c32 100644 --- a/docs/CustomSource.wiki.md +++ b/docs/CustomSource.wiki.md @@ -33,7 +33,7 @@ To change minifier, set `minifier` to a [callback](http://php.net/manual/en/lang ``` if (! function_exists('myMin')) { function myMin($js) { - require_once 'JSMinPlus.php'; + require_once '/path/to/jsminplus.php'; return JSMinPlus::minify($js); } } diff --git a/min/lib/DooDigestAuth.php b/min/lib/DooDigestAuth.php index 69bc4ed..5a9b467 100644 --- a/min/lib/DooDigestAuth.php +++ b/min/lib/DooDigestAuth.php @@ -23,6 +23,8 @@ * @version $Id: DooDigestAuth.php 1000 2009-07-7 18:27:22 * @package doo.auth * @since 1.0 + * + * @deprecated 2.3 This will be removed in Minify 3.0 */ class DooDigestAuth{ diff --git a/min/lib/FirePHP.php b/min/lib/FirePHP.php index 8fff783..bf4fb70 100644 --- a/min/lib/FirePHP.php +++ b/min/lib/FirePHP.php @@ -64,6 +64,8 @@ if (!defined('E_USER_DEPRECATED')) { * @author Christoph Dorn * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) * @package FirePHPCore + * + * @deprecated 2.3 This will be removed in Minify 3.0 */ class FirePHP { diff --git a/min/lib/JSMinPlus.php b/min/lib/JSMinPlus.php index 5a3c5bd..1c7463c 100644 --- a/min/lib/JSMinPlus.php +++ b/min/lib/JSMinPlus.php @@ -170,7 +170,9 @@ define('KEYWORD_VOID', 'void'); define('KEYWORD_WHILE', 'while'); define('KEYWORD_WITH', 'with'); - +/** + * @deprecated 2.3 This will be removed in Minify 3.0 + */ class JSMinPlus { private $parser; @@ -197,6 +199,8 @@ class JSMinPlus public static function minify($js, $filename='') { + trigger_error(__CLASS__ . ' is deprecated. This will be removed in Minify 3.0', E_USER_DEPRECATED); + static $instance; // this is a singleton diff --git a/min/lib/Minify/Loader.php b/min/lib/Minify/Loader.php index 0a225c0..ca43192 100644 --- a/min/lib/Minify/Loader.php +++ b/min/lib/Minify/Loader.php @@ -9,6 +9,8 @@ * * @package Minify * @author Stephen Clay + * + * @deprecated 2.3 This will be removed in Minify 3.0 */ class Minify_Loader { public function loadClass($class) @@ -20,6 +22,9 @@ class Minify_Loader { } } + /** + * @deprecated 2.3 This will be removed in Minify 3.0 + */ static public function register() { $inst = new self(); diff --git a/min/lib/Minify/Logger.php b/min/lib/Minify/Logger.php index 8eb72f4..5217441 100644 --- a/min/lib/Minify/Logger.php +++ b/min/lib/Minify/Logger.php @@ -10,7 +10,7 @@ * @package Minify * @author Stephen Clay * - * @todo lose this singleton! pass log object in Minify::serve and distribute to others + * @deprecated 2.3 This will be removed in Minify 3.0 */ class Minify_Logger { From 2d3c417a516750853bc23c6176e900d4efa6bb3d Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Fri, 11 Mar 2016 23:08:29 -0500 Subject: [PATCH 2/6] Update README.md Add news --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index c51b193..356c33b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ The stats above are from a [brief walkthrough](http://mrclay.org/index.php/2008/ Relative URLs in CSS files are rewritten to compensate for being served from a different directory. +News +---- + +Version [2.3.0](https://github.com/mrclay/minify/releases/tag/2.3.0) was released, mainly to deprecate some classes that will be removed in 3.0. + Wordpress User? --------------- From 0eb2cfe78d07c2462362c90727c72022a6007195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 13 Mar 2016 14:55:23 +0200 Subject: [PATCH 3/6] Update README.md fixes from googlecode migration --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 356c33b..e896bb5 100644 --- a/README.md +++ b/README.md @@ -81,4 +81,4 @@ Acknowledgments Minify was inspired by [jscsscomp](http://code.google.com/p/jscsscomp/) by Maxim Martynyuk and by the article [Supercharged JavaScript](http://www.hunlock.com/blogs/Supercharged_Javascript) by Patrick Hunlock. -The [JSMin library](http://www.crockford.com/javascript/jsmin.html) used for !JavaScript minification was originally written by Douglas Crockford and was [ported to PHP](https://github.com/mrclay/jsmin-php) by Ryan Grove specifically for use in Minify. +The [JSMin library](http://www.crockford.com/javascript/jsmin.html) used for JavaScript minification was originally written by Douglas Crockford and was [ported to PHP](https://github.com/mrclay/jsmin-php) by Ryan Grove specifically for use in Minify. From cff094781ba46cc3636e9fe546ea0c5b39c670bf Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Wed, 16 Mar 2016 18:32:47 -0400 Subject: [PATCH 4/6] No longer alters inline SVG id URLs Fixes #517 --- min/lib/Minify/CSS/UriRewriter.php | 38 ++++++++++++++++++- .../_test_files/css_uriRewriter/exp.css | 4 ++ .../css_uriRewriter/exp_prepend.css | 4 ++ .../css_uriRewriter/exp_prepend2.css | 4 ++ .../_test_files/css_uriRewriter/in.css | 4 ++ 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/min/lib/Minify/CSS/UriRewriter.php b/min/lib/Minify/CSS/UriRewriter.php index 43cc254..e963fb8 100644 --- a/min/lib/Minify/CSS/UriRewriter.php +++ b/min/lib/Minify/CSS/UriRewriter.php @@ -66,16 +66,20 @@ class Minify_CSS_UriRewriter { self::$debugText .= "\n"; $css = self::_trimUrls($css); - + + $css = self::_owlifySvgPaths($css); + // rewrite $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/' ,array(self::$className, '_processUriCB'), $css); $css = preg_replace_callback('/url\\(\\s*([\'"](.*?)[\'"]|[^\\)\\s]+)\\s*\\)/' ,array(self::$className, '_processUriCB'), $css); + $css = self::_unOwlify($css); + return $css; } - + /** * In CSS content, prepend a path to relative URIs * @@ -90,6 +94,8 @@ class Minify_CSS_UriRewriter { self::$_prependPath = $path; $css = self::_trimUrls($css); + + $css = self::_owlifySvgPaths($css); // append $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/' @@ -97,6 +103,8 @@ class Minify_CSS_UriRewriter { $css = preg_replace_callback('/url\\(\\s*([\'"](.*?)[\'"]|[^\\)\\s]+)\\s*\\)/' ,array(self::$className, '_processUriCB'), $css); + $css = self::_unOwlify($css); + self::$_prependPath = null; return $css; } @@ -304,4 +312,30 @@ class Minify_CSS_UriRewriter { ? "@import {$quoteChar}{$uri}{$quoteChar}" : "url({$quoteChar}{$uri}{$quoteChar})"; } + + /** + * Mungs some inline SVG URL declarations so they won't be touched + * + * @link https://github.com/mrclay/minify/issues/517 + * @see _unOwlify + * + * @param string $css + * @return string + */ + private static function _owlifySvgPaths($css) { + return preg_replace('~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)url(\(\s*#\w+\s*\))~', '$1owl$2', $css); + + } + + /** + * Undo work of _owlify + * + * @see _owlifySvgPaths + * + * @param string $css + * @return string + */ + private static function _unOwlify($css) { + return preg_replace('~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)owl~', '$1url', $css); + } } diff --git a/min_unit_tests/_test_files/css_uriRewriter/exp.css b/min_unit_tests/_test_files/css_uriRewriter/exp.css index 22c109f..3296c26 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/exp.css +++ b/min_unit_tests/_test_files/css_uriRewriter/exp.css @@ -8,6 +8,10 @@ @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ @import url(foo:bar); /* scheme, should not alter */ +foo {clip-path:url(#c1)} /* inline clip path, should not alter */ +foo {clip-path:url(/_test_files/css_uriRewriter/foo.svg#c1)} +foo {mask: url(#c1)} /* should not alter */ +foo {-webkit-mask: url(#c1)} /* should not alter */ foo {background:url('/_test_files/css_uriRewriter/bar/foo.png')} foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ diff --git a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css index ce31df1..bc09c44 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css +++ b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css @@ -8,6 +8,10 @@ @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ @import url(foo:bar); /* scheme, should not alter */ +foo {clip-path:url(#c1)} /* inline clip path, should not alter */ +foo {clip-path:url(http://cnd.com/A/B/foo.svg#c1)} +foo {mask: url(#c1)} /* should not alter */ +foo {-webkit-mask: url(#c1)} /* should not alter */ foo {background:url('http://cnd.com/A/B/bar/foo.png')} foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ diff --git a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css index 087d94d..c8f7c61 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css +++ b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css @@ -8,6 +8,10 @@ @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ @import url(foo:bar); /* scheme, should not alter */ +foo {clip-path:url(#c1)} /* inline clip path, should not alter */ +foo {clip-path:url(//cnd.com/A/B/foo.svg#c1)} +foo {mask: url(#c1)} /* should not alter */ +foo {-webkit-mask: url(#c1)} /* should not alter */ foo {background:url('//cnd.com/A/B/bar/foo.png')} foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ diff --git a/min_unit_tests/_test_files/css_uriRewriter/in.css b/min_unit_tests/_test_files/css_uriRewriter/in.css index 3bdce36..0200450 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/in.css +++ b/min_unit_tests/_test_files/css_uriRewriter/in.css @@ -8,6 +8,10 @@ @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ @import url(foo:bar); /* scheme, should not alter */ +foo {clip-path:url(#c1)} /* inline clip path, should not alter */ +foo {clip-path:url(foo.svg#c1)} +foo {mask: url( #c1 )} /* should not alter */ +foo {-webkit-mask: url( #c1 )} /* should not alter */ foo {background:url('bar/foo.png')} foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ From 28197576c69fedb985e7488bf6d2af5002534f54 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Mon, 18 Apr 2016 21:02:00 -0400 Subject: [PATCH 5/6] Use $min_libPath in examples and move it within config.php Fixes #522 --- docs/CookBook.wiki.md | 4 ++-- min/config.php | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/CookBook.wiki.md b/docs/CookBook.wiki.md index 975ddfc..6229cd2 100644 --- a/docs/CookBook.wiki.md +++ b/docs/CookBook.wiki.md @@ -7,7 +7,7 @@ By default, Minify uses [Minify\_Cache\_File](http://code.google.com/p/minify/so ### APC ``` -require 'lib/Minify/Cache/APC.php'; +require "$min_libPath/Minify/Cache/APC.php"; $min_cachePath = new Minify_Cache_APC(); ``` @@ -15,7 +15,7 @@ $min_cachePath = new Minify_Cache_APC(); You must create and connect your Memcache object then pass it to `Minify_Cache_Memcache`'s constructor. ``` -require 'lib/Minify/Cache/Memcache.php'; +require "$min_libPath/Minify/Cache/Memcache.php"; $memcache = new Memcache; $memcache->connect('localhost', 11211); $min_cachePath = new Minify_Cache_Memcache($memcache); diff --git a/min/config.php b/min/config.php index 3b5fd2b..d5d413d 100644 --- a/min/config.php +++ b/min/config.php @@ -60,11 +60,19 @@ $min_allowDebugFlag = false; //$min_cachePath = '/tmp'; //$min_cachePath = preg_replace('/^\\d+;/', '', session_save_path()); + +/** + * Path to Minify's lib folder. If you happen to move it, change + * this accordingly. + */ +$min_libPath = dirname(__FILE__) . '/lib'; + + /** * To use APC/Memcache/ZendPlatform for cache storage, require the class and * set $min_cachePath to an instance. Example below: */ -//require dirname(__FILE__) . '/lib/Minify/Cache/APC.php'; +//require "$min_libPath/Minify/Cache/APC.php"; //$min_cachePath = new Minify_Cache_APC(); @@ -187,12 +195,5 @@ $min_symlinks = array(); $min_uploaderHoursBehind = 0; -/** - * Path to Minify's lib folder. If you happen to move it, change - * this accordingly. - */ -$min_libPath = dirname(__FILE__) . '/lib'; - - // try to disable output_compression (may not have an effect) ini_set('zlib.output_compression', '0'); From 6a2995f93256a54928f7413bf26971e92ed43d2b Mon Sep 17 00:00:00 2001 From: Evgeny Mazovetskiy Date: Mon, 9 May 2016 17:29:08 +0200 Subject: [PATCH 6/6] list allowDirs in exception to simplify debugging --- min/lib/Minify/Controller/Base.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/min/lib/Minify/Controller/Base.php b/min/lib/Minify/Controller/Base.php index 4e43013..3ed3028 100644 --- a/min/lib/Minify/Controller/Base.php +++ b/min/lib/Minify/Controller/Base.php @@ -126,7 +126,9 @@ abstract class Minify_Controller_Base { return true; } } - throw new Exception("File '$file' is outside \$allowDirs. If the path is" + + $allowDirs = implode(';', array_values($allowDirs)); + throw new Exception("File '$file' is outside \$allowDirs ($allowDirs). If the path is" . " resolved via an alias/symlink, look into the \$min_symlinks option." . " E.g. \$min_symlinks['/" . dirname($uri) . "'] = '" . dirname($file) . "';"); }