1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-10 16:14:18 +02:00

+ URI rewriter in CSS min, fix for protocol-relative URIs, + partial minify.php compatibility

This commit is contained in:
Steve Clay
2008-03-01 20:23:50 +00:00
parent 381bd8856d
commit d86d79b7d2
8 changed files with 169 additions and 52 deletions

View File

@@ -88,6 +88,32 @@ abstract class Minify_Controller_Base {
}
}
/**
* Is a user-given file within document root, existing,
* and having an extension js/css/html/txt
*
* This is a convenience function for controllers that have to accept
* user-given paths
*
* @param string $file full file path (already processed by realpath())
* @param string $docRoot root where files are safe to serve
* @return bool file is safe
*/
public static function _fileIsSafe($file, $docRoot)
{
if (strpos($file, $docRoot) !== 0 || ! file_exists($file)) {
return false;
}
$base = basename($file);
if ($base[0] === '.') {
return false;
}
list($revExt) = explode('.', strrev($base));
return in_array(strrev($revExt), array('js', 'css', 'html', 'txt'));
}
/*public static function _haveSameExt
/**
* @var array instances of Minify_Source, which provide content and
* any individual minification needs.
@@ -125,7 +151,8 @@ abstract class Minify_Controller_Base {
*
* @return array options for Minify
*/
public final function analyzeSources($options = array()) {
public final function analyzeSources($options = array())
{
if ($this->sources) {
if (! isset($options['contentType'])) {
$options['contentType'] = Minify_Source::getContentType($this->sources);