mirror of
https://github.com/mrclay/minify.git
synced 2025-08-24 22:45:51 +02:00
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,5 +6,5 @@
|
||||
|
||||
/.idea/
|
||||
/composer.lock
|
||||
/vendor/
|
||||
/vendor
|
||||
/.php_cs.cache
|
||||
|
@@ -5,6 +5,7 @@
|
||||
* Removes DooDigestAuth
|
||||
* Removes Minify_Loader (uses Composer)
|
||||
* Removes Minify_Logger (uses Monolog)
|
||||
* Removes `$min_libPath` option
|
||||
* The Minify, source, and controller components have changed APIs
|
||||
* Better CSS minification via Túbal Martín's CSSMin
|
||||
* Add config option for simply concatenating files
|
||||
@@ -12,6 +13,14 @@
|
||||
* Missing spec no longer redirects, instead links to docs
|
||||
* Minify::VERSION is an int that tracks the major version number
|
||||
|
||||
## Version 2.3.0 (2016-03-11)
|
||||
* 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.1 (2014-10-30)
|
||||
* Builder styled with Bootstrap (thanks to help from acidvertigo)
|
||||
* Update CSSmin to v.2.4.8
|
||||
|
@@ -56,6 +56,7 @@ $min_allowDebugFlag = false;
|
||||
//$min_cachePath = '/tmp';
|
||||
//$min_cachePath = preg_replace('/^\\d+;/', '', session_save_path());
|
||||
|
||||
|
||||
/**
|
||||
* To use APC/Memcache/ZendPlatform for cache storage, require the class and
|
||||
* set $min_cachePath to an instance. Example below:
|
||||
|
@@ -67,12 +67,16 @@ class Minify_CSS_UriRewriter {
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -91,12 +95,16 @@ class Minify_CSS_UriRewriter {
|
||||
|
||||
$css = self::_trimUrls($css);
|
||||
|
||||
$css = self::_owlifySvgPaths($css);
|
||||
|
||||
// append
|
||||
$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);
|
||||
|
||||
self::$_prependPath = null;
|
||||
|
||||
return $css;
|
||||
@@ -308,4 +316,29 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@@ -157,16 +157,19 @@ class Minify_Source_Factory {
|
||||
}
|
||||
|
||||
if ($this->options['checkAllowDirs']) {
|
||||
$allowDirs = (array)$this->options['allowDirs'];
|
||||
$inAllowedDir = false;
|
||||
foreach ((array)$this->options['allowDirs'] as $allowDir) {
|
||||
foreach ($allowDirs as $allowDir) {
|
||||
if (strpos($this->getNormalizedPath($spec['filepath']), $this->getNormalizedPath($allowDir)) === 0) {
|
||||
$inAllowedDir = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$inAllowedDir) {
|
||||
throw new Minify_Source_FactoryException("File '{$spec['filepath']}' is outside \$allowDirs."
|
||||
. " If the path is resolved via an alias/symlink, look into the \$min_symlinks option.");
|
||||
$allowDirsStr = implode(';', $allowDirs);
|
||||
throw new Minify_Source_FactoryException("File '{$spec['filepath']}' is outside \$allowDirs "
|
||||
. "($allowDirsStr). If the path is resolved via an alias/symlink, look into the "
|
||||
. "\$min_symlinks option.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -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 */
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user