mirror of
https://github.com/mrclay/minify.git
synced 2025-08-15 02:24:13 +02:00
Merge branch '2.x' into merge2x
Conflicts: .gitignore HISTORY.txt README.md config.php docs/CookBook.wiki.md docs/CustomSource.wiki.md lib/Minify/CSS/UriRewriter.php min/lib/DooDigestAuth.php min/lib/FirePHP.php min/lib/JSMinPlus.php min/lib/Minify/Controller/Base.php min/lib/Minify/Loader.php min/lib/Minify/Logger.php
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user