1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-17 03:24:01 +02:00

Work on: Issue 125, Issue 126, Issue 132, Issue 134, Issue 138, Issue 139, Issue 147, Issue 149, Issue 151, Issue 162, Issue 166

This commit is contained in:
Steve Clay
2010-05-09 16:43:47 +00:00
parent 5205a42f99
commit f4c688b338
26 changed files with 236 additions and 155 deletions

View File

@@ -197,6 +197,7 @@ var MUB = {
* Runs on DOMready * Runs on DOMready
*/ */
,init : function () { ,init : function () {
$('#jsDidntLoad').hide();
$('#app').show(); $('#app').show();
$('#sources').html(''); $('#sources').html('');
$('#add button').click(MUB.addButtonClick); $('#add button').click(MUB.addButtonClick);
@@ -239,4 +240,4 @@ var MUB = {
MUB.checkRewrite(); MUB.checkRewrite();
} }
}; };
window.onload = MUB.init; $(MUB.init);

View File

@@ -17,11 +17,10 @@ if (! $min_enableBuilder) {
ob_start(); ob_start();
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML>
<head> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> <title>Minify URI Builder</title>
<title>Minify URI Builder</title> <style type="text/css">
<style type="text/css">
body {margin:1em 60px;} body {margin:1em 60px;}
h1, h2, h3 {margin-left:-25px; position:relative;} h1, h2, h3 {margin-left:-25px; position:relative;}
h1 {margin-top:0;} h1 {margin-top:0;}
@@ -37,8 +36,13 @@ h1 {margin-top:0;}
b {color:#c00} b {color:#c00}
.topNote {background: #ff9; display:inline-block; padding:.5em .6em; margin:0 0 1em;} .topNote {background: #ff9; display:inline-block; padding:.5em .6em; margin:0 0 1em;}
.topWarning {background:#c00; color:#fff; padding:.5em .6em; margin:0 0 1em;} .topWarning {background:#c00; color:#fff; padding:.5em .6em; margin:0 0 1em;}
</style> .topWarning a {color:#fff;}
</head> </style>
<body>
<p class=topWarning id=jsDidntLoad><strong>Uh Oh.</strong> Minify was unable to
serve the Javascript for this app. <a href="http://code.google.com/p/minify/wiki/Debugging">Enable
FirePHP debugging</a> and request the <a id=builderScriptSrc href=#>Minify URL</a> directly.
</p>
<?php if (! isset($min_cachePath)): ?> <?php if (! isset($min_cachePath)): ?>
<p class=topNote><strong>Note:</strong> Please set <code>$min_cachePath</code> <p class=topNote><strong>Note:</strong> Please set <code>$min_cachePath</code>
@@ -149,11 +153,15 @@ $(function () {
}); });
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
// workaround required to test when /min isn't child of web root // workaround required to test when /min isn't child of web root
var src = location.pathname.replace(/\/[^\/]*$/, '/_index.js').substr(1); var src = location.pathname.replace(/\/[^\/]*$/, '/_index.js').substr(1);
document.write('<\script type="text/javascript" src="../?f=' + src + '"><\/script>'); src = "../?f=" + src;
document.write('<\script type="text/javascript" src="' + src + '"><\/script>');
$(function () {
$('#builderScriptSrc')[0].href = src;
});
</script> </script>
</body>
<?php <?php
$serveOpts = array( $serveOpts = array(

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* Configuration for default Minify application * Configuration for "min", the default application built with the Minify
* library
*
* @package Minify * @package Minify
*/ */
@@ -78,9 +80,9 @@ $min_serveOptions['bubbleCssImports'] = false;
/** /**
* Maximum age of browser cache in seconds. After this period, the browser * Cache-Control: max-age value sent to browser (in seconds). After this period,
* will send another conditional GET. Use a longer period for lower traffic * the browser will send another conditional GET. Use a longer period for lower
* but you may want to shorten this before making changes if it's crucial * traffic but you may want to shorten this before making changes if it's crucial
* those changes are seen immediately. * those changes are seen immediately.
* *
* Note: Despite this setting, if you include a number at the end of the * Note: Despite this setting, if you include a number at the end of the
@@ -105,10 +107,15 @@ $min_serveOptions['maxAge'] = 1800;
*/ */
$min_serveOptions['minApp']['groupsOnly'] = false; $min_serveOptions['minApp']['groupsOnly'] = false;
/** /**
* Maximum # of files that can be specified in the "f" GET parameter * By default, Minify will not minify files with names containing .min or -min
* before the extension. E.g. myFile.min.js will not be processed by JSMin
*
* To minify all files, set this option to null. You could also specify your
* own pattern that is matched against the filename.
*/ */
$min_serveOptions['minApp']['maxFiles'] = 10; //$min_serveOptions['minApp']['noMinPattern'] = '@[-\\.]min\\.(?:js|css)$@i';
/** /**

View File

@@ -7,28 +7,12 @@
/** /**
* You may wish to use the Minify URI Builder app to suggest * You may wish to use the Minify URI Builder app to suggest
* changes. http://yourdomain/min/builder/ * changes. http://yourdomain/min/builder/
*
* See http://code.google.com/p/minify/wiki/CustomSource for other ideas
**/ **/
return array( return array(
// 'js' => array('//js/file1.js', '//js/file2.js'), // 'js' => array('//js/file1.js', '//js/file2.js'),
// 'css' => array('//css/file1.css', '//css/file2.css'), // 'css' => array('//css/file1.css', '//css/file2.css'),
// custom source example
/*'js2' => array(
dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
// do NOT process this file
new Minify_Source(array(
'filepath' => dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
'minifier' => create_function('$a', 'return $a;')
))
),//*/
/*'js3' => array(
dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
// do NOT process this file
new Minify_Source(array(
'filepath' => dirname(__FILE__) . '/../min_unit_tests/_test_files/js/before.js',
'minifier' => array('Minify_Packer', 'minify')
))
),//*/
); );

View File

@@ -30,6 +30,10 @@ if ($min_documentRoot) {
} }
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks; $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
// auto-add targets to allowDirs
foreach ($min_symlinks as $uri => $target) {
$min_serveOptions['minApp']['allowDirs'][] = $target;
}
if ($min_allowDebugFlag && isset($_GET['debug'])) { if ($min_allowDebugFlag && isset($_GET['debug'])) {
$min_serveOptions['debug'] = true; $min_serveOptions['debug'] = true;

View File

@@ -337,7 +337,7 @@ class HTTP_ConditionalGet {
// IE has tacked on extra data to this header, strip it // IE has tacked on extra data to this header, strip it
$ifModifiedSince = substr($ifModifiedSince, 0, $semicolon); $ifModifiedSince = substr($ifModifiedSince, 0, $semicolon);
} }
if ($ifModifiedSince == self::gmtDate($this->_lmTime)) { if (strtotime($ifModifiedSince) >= $this->_lmTime) {
// Apache 2.2's behavior. If there was no ETag match, send the // Apache 2.2's behavior. If there was no ETag match, send the
// non-encoded version of the ETag value. // non-encoded version of the ETag value.
$this->_headers['ETag'] = $this->normalizeEtag($this->_etag); $this->_headers['ETag'] = $this->normalizeEtag($this->_etag);

View File

@@ -59,7 +59,7 @@ class HTTP_Encoder {
* *
* @var bool * @var bool
*/ */
public static $encodeToIe6 = false; public static $encodeToIe6 = true;
/** /**
@@ -195,7 +195,7 @@ class HTTP_Encoder {
// @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
if (! isset($_SERVER['HTTP_ACCEPT_ENCODING']) if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
|| self::_isBuggyIe()) || self::isBuggyIe())
{ {
return array('', ''); return array('', '');
} }
@@ -253,7 +253,9 @@ class HTTP_Encoder {
*/ */
public function encode($compressionLevel = null) public function encode($compressionLevel = null)
{ {
if (! self::isBuggyIe()) {
$this->_headers['Vary'] = 'Accept-Encoding'; $this->_headers['Vary'] = 'Accept-Encoding';
}
if (null === $compressionLevel) { if (null === $compressionLevel) {
$compressionLevel = self::$compressionLevel; $compressionLevel = self::$compressionLevel;
} }
@@ -302,14 +304,12 @@ class HTTP_Encoder {
return $ret; return $ret;
} }
protected $_content = '';
protected $_headers = array();
protected $_encodeMethod = array('', '');
/** /**
* Is the browser an IE version earlier than 6 SP2? * Is the browser an IE version earlier than 6 SP2?
*
* @return bool
*/ */
protected static function _isBuggyIe() public static function isBuggyIe()
{ {
$ua = $_SERVER['HTTP_USER_AGENT']; $ua = $_SERVER['HTTP_USER_AGENT'];
// quick escape for non-IEs // quick escape for non-IEs
@@ -323,4 +323,8 @@ class HTTP_Encoder {
? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1'))) ? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1')))
: ($version < 7); : ($version < 7);
} }
protected $_content = '';
protected $_headers = array();
protected $_encodeMethod = array('', '');
} }

View File

@@ -171,7 +171,7 @@ class JSMin {
} }
if (ord($this->a) <= self::ORD_LF) { if (ord($this->a) <= self::ORD_LF) {
throw new JSMin_UnterminatedStringException( throw new JSMin_UnterminatedStringException(
'Unterminated String: ' . var_export($str, true)); "Unterminated String: {$str}");
} }
$str .= $this->a; $str .= $this->a;
if ($this->a === '\\') { if ($this->a === '\\') {
@@ -198,7 +198,7 @@ class JSMin {
$pattern .= $this->a; $pattern .= $this->a;
} elseif (ord($this->a) <= self::ORD_LF) { } elseif (ord($this->a) <= self::ORD_LF) {
throw new JSMin_UnterminatedRegExpException( throw new JSMin_UnterminatedRegExpException(
'Unterminated RegExp: '. var_export($pattern, true)); "Unterminated RegExp: {$pattern}");
} }
$this->output .= $this->a; $this->output .= $this->a;
} }
@@ -310,7 +310,7 @@ class JSMin {
return ' '; return ' ';
} }
} elseif ($get === null) { } elseif ($get === null) {
throw new JSMin_UnterminatedCommentException('Unterminated Comment: ' . var_export('/*' . $comment, true)); throw new JSMin_UnterminatedCommentException("Unterminated Comment: /*{$comment}");
} }
$comment .= $get; $comment .= $get;
} }

View File

@@ -35,6 +35,7 @@ class Minify {
// there is some debate over the ideal JS Content-Type, but this is the // there is some debate over the ideal JS Content-Type, but this is the
// Apache default and what Yahoo! uses.. // Apache default and what Yahoo! uses..
const TYPE_JS = 'application/x-javascript'; const TYPE_JS = 'application/x-javascript';
const URL_DEBUG = 'http://code.google.com/p/minify/wiki/Debugging';
/** /**
* How many hours behind are the file modification times of uploaded files? * How many hours behind are the file modification times of uploaded files?
@@ -179,9 +180,7 @@ class Minify {
if (! $controller->sources) { if (! $controller->sources) {
// invalid request! // invalid request!
if (! self::$_options['quiet']) { if (! self::$_options['quiet']) {
header(self::$_options['badRequestHeader']); self::_errorExit(self::$_options['badRequestHeader'], self::URL_DEBUG);
echo self::$_options['badRequestHeader'];
return;
} else { } else {
list(,$statusCode) = explode(' ', self::$_options['badRequestHeader']); list(,$statusCode) = explode(' ', self::$_options['badRequestHeader']);
return array( return array(
@@ -202,6 +201,7 @@ class Minify {
// determine encoding // determine encoding
if (self::$_options['encodeOutput']) { if (self::$_options['encodeOutput']) {
$sendVary = true;
if (self::$_options['encodeMethod'] !== null) { if (self::$_options['encodeMethod'] !== null) {
// controller specifically requested this // controller specifically requested this
$contentEncoding = self::$_options['encodeMethod']; $contentEncoding = self::$_options['encodeMethod'];
@@ -212,6 +212,7 @@ class Minify {
// 'x-gzip' while our internal encodeMethod is 'gzip'. Calling // 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
// getAcceptedEncoding(false, false) leaves out compress and deflate as options. // getAcceptedEncoding(false, false) leaves out compress and deflate as options.
list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(false, false); list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(false, false);
$sendVary = ! HTTP_Encoder::isBuggyIe();
} }
} else { } else {
self::$_options['encodeMethod'] = ''; // identity (no encoding) self::$_options['encodeMethod'] = ''; // identity (no encoding)
@@ -261,7 +262,7 @@ class Minify {
} }
// check server cache // check server cache
if (null !== self::$_cache) { if (null !== self::$_cache && ! self::$_options['debug']) {
// using cache // using cache
// the goal is to use only the cache methods to sniff the length and // the goal is to use only the cache methods to sniff the length and
// output the content, as they do not require ever loading the file into // output the content, as they do not require ever loading the file into
@@ -276,7 +277,15 @@ class Minify {
$cacheContentLength = self::$_cache->getSize($fullCacheId); $cacheContentLength = self::$_cache->getSize($fullCacheId);
} else { } else {
// generate & cache content // generate & cache content
try {
$content = self::_combineMinify(); $content = self::_combineMinify();
} catch (Exception $e) {
self::$_controller->log($e->getMessage());
if (! self::$_options['quiet']) {
self::_errorExit(self::$_options['errorHeader'], self::URL_DEBUG);
}
throw $e;
}
self::$_cache->store($cacheId, $content); self::$_cache->store($cacheId, $content);
if (function_exists('gzencode')) { if (function_exists('gzencode')) {
self::$_cache->store($cacheId . '.gz', gzencode($content, self::$_options['encodeLevel'])); self::$_cache->store($cacheId . '.gz', gzencode($content, self::$_options['encodeLevel']));
@@ -285,7 +294,15 @@ class Minify {
} else { } else {
// no cache // no cache
$cacheIsReady = false; $cacheIsReady = false;
try {
$content = self::_combineMinify(); $content = self::_combineMinify();
} catch (Exception $e) {
self::$_controller->log($e->getMessage());
if (! self::$_options['quiet']) {
self::_errorExit(self::$_options['errorHeader'], self::URL_DEBUG);
}
throw $e;
}
} }
if (! $cacheIsReady && self::$_options['encodeMethod']) { if (! $cacheIsReady && self::$_options['encodeMethod']) {
// still need to encode // still need to encode
@@ -293,16 +310,22 @@ class Minify {
} }
// add headers // add headers
$hasMbOverload = (function_exists('mb_strlen')
&& (ini_get('mbstring.func_overload') !== '')
&& ((int)ini_get('mbstring.func_overload') & 2));
$headers['Content-Length'] = $cacheIsReady $headers['Content-Length'] = $cacheIsReady
? $cacheContentLength ? $cacheContentLength
: strlen($content); : ($hasMbOverload
? mb_strlen($content, '8bit')
: strlen($content)
);
$headers['Content-Type'] = self::$_options['contentTypeCharset'] $headers['Content-Type'] = self::$_options['contentTypeCharset']
? self::$_options['contentType'] . '; charset=' . self::$_options['contentTypeCharset'] ? self::$_options['contentType'] . '; charset=' . self::$_options['contentTypeCharset']
: self::$_options['contentType']; : self::$_options['contentType'];
if (self::$_options['encodeMethod'] !== '') { if (self::$_options['encodeMethod'] !== '') {
$headers['Content-Encoding'] = $contentEncoding; $headers['Content-Encoding'] = $contentEncoding;
} }
if (self::$_options['encodeOutput']) { if (self::$_options['encodeOutput'] && $sendVary) {
$headers['Vary'] = 'Accept-Encoding'; $headers['Vary'] = 'Accept-Encoding';
} }
@@ -369,9 +392,9 @@ class Minify {
&& 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/') && 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')
) { ) {
$_SERVER['DOCUMENT_ROOT'] = rtrim(substr( $_SERVER['DOCUMENT_ROOT'] = rtrim(substr(
$_SERVER['PATH_TRANSLATED'] $_SERVER['SCRIPT_FILENAME']
,0 ,0
,strlen($_SERVER['PATH_TRANSLATED']) - strlen($_SERVER['SCRIPT_NAME']) ,strlen($_SERVER['SCRIPT_FILENAME']) - strlen($_SERVER['SCRIPT_NAME'])
), '\\'); ), '\\');
if ($unsetPathInfo) { if ($unsetPathInfo) {
unset($_SERVER['PATH_INFO']); unset($_SERVER['PATH_INFO']);
@@ -396,6 +419,18 @@ class Minify {
*/ */
protected static $_options = null; protected static $_options = null;
protected static function _errorExit($header, $url)
{
$url = htmlspecialchars($url, ENT_QUOTES);
list(,$h1) = explode(' ', $header, 2);
$h1 = htmlspecialchars($h1);
header($header);
header('Content-Type: text/html; charset=utf-8');
echo "<h1>$h1</h1>";
echo "<p>Please see <a href='$url'>$url</a>.</p>";
exit();
}
/** /**
* Set up sources to use Minify_Lines * Set up sources to use Minify_Lines
* *
@@ -440,19 +475,9 @@ class Minify {
? self::$_options['minifiers'][$type] ? self::$_options['minifiers'][$type]
: false; : false;
if (Minify_Source::haveNoMinifyPrefs(self::$_controller->sources)) { // minify each source with its own options and minifier, then combine.
// all source have same options/minifier, better performance // Here we used to combine all first but this was probably
// to combine, then minify once // bad for PCRE performance, esp. in CSS.
foreach (self::$_controller->sources as $source) {
$pieces[] = $source->getContent();
}
$content = implode($implodeSeparator, $pieces);
if ($defaultMinifier) {
self::$_controller->loadMinifier($defaultMinifier);
$content = call_user_func($defaultMinifier, $content, $defaultOptions);
}
} else {
// minify each source with its own options and minifier, then combine
foreach (self::$_controller->sources as $source) { foreach (self::$_controller->sources as $source) {
// allow the source to override our minifier and options // allow the source to override our minifier and options
$minifier = (null !== $source->minifier) $minifier = (null !== $source->minifier)
@@ -470,7 +495,6 @@ class Minify {
} }
} }
$content = implode($implodeSeparator, $pieces); $content = implode($implodeSeparator, $pieces);
}
if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) { if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) {
$content = self::_handleCssImports($content); $content = self::_handleCssImports($content);

View File

@@ -108,7 +108,7 @@ class Minify_CSS_Compressor {
\\s* \\s*
: :
\\s* \\s*
(\\b|[#\'"]) # 3 = first character of a value (\\b|[#\'"-]) # 3 = first character of a value
/x', '$1$2:$3', $css); /x', '$1$2:$3', $css);
// remove ws in selectors // remove ws in selectors

View File

@@ -55,6 +55,7 @@ abstract class Minify_Controller_Base {
// if you override this, the response code MUST be directly after // if you override this, the response code MUST be directly after
// the first space. // the first space.
,'badRequestHeader' => 'HTTP/1.0 400 Bad Request' ,'badRequestHeader' => 'HTTP/1.0 400 Bad Request'
,'errorHeader' => 'HTTP/1.0 500 Internal Server Error'
// callback function to see/modify content of all sources // callback function to see/modify content of all sources
,'postprocessor' => null ,'postprocessor' => null
@@ -195,7 +196,7 @@ abstract class Minify_Controller_Base {
* @param string $msg * @param string $msg
* @return null * @return null
*/ */
protected function log($msg) { public function log($msg) {
require_once 'Minify/Logger.php'; require_once 'Minify/Logger.php';
Minify_Logger::log($msg); Minify_Logger::log($msg);
} }

View File

@@ -28,7 +28,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
'allowDirs' => '//' 'allowDirs' => '//'
,'groupsOnly' => false ,'groupsOnly' => false
,'groups' => array() ,'groups' => array()
,'maxFiles' => 10 ,'noMinPattern' => '@[-\\.]min\\.(?:js|css)$@i' // matched against basename
) )
,(isset($options['minApp']) ? $options['minApp'] : array()) ,(isset($options['minApp']) ? $options['minApp'] : array())
); );
@@ -58,9 +58,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
} }
$file = realpath($file); $file = realpath($file);
if (is_file($file)) { if (is_file($file)) {
$sources[] = new Minify_Source(array( $sources[] = $this->_getFileSource($file, $cOptions);
'filepath' => $file
));
} else { } else {
$this->log("The path \"{$file}\" could not be found (or was not a file)"); $this->log("The path \"{$file}\" could not be found (or was not a file)");
return $options; return $options;
@@ -84,8 +82,8 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
return $options; return $options;
} }
$files = explode(',', $_GET['f']); $files = explode(',', $_GET['f']);
if (count($files) > $cOptions['maxFiles'] || $files != array_unique($files)) { if ($files != array_unique($files)) {
$this->log("Too many or duplicate files specified"); $this->log("Duplicate files specified");
return $options; return $options;
} }
if (isset($_GET['b'])) { if (isset($_GET['b'])) {
@@ -116,9 +114,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$this->log("Path \"{$path}\" failed Minify_Controller_Base::_fileIsSafe()"); $this->log("Path \"{$path}\" failed Minify_Controller_Base::_fileIsSafe()");
return $options; return $options;
} else { } else {
$sources[] = new Minify_Source(array( $sources[] = $this->_getFileSource($file, $cOptions);
'filepath' => $file
));
} }
} }
} }
@@ -129,4 +125,14 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
} }
return $options; return $options;
} }
protected function _getFileSource($file, $cOptions)
{
$spec['filepath'] = $file;
if ($cOptions['noMinPattern']
&& preg_match($cOptions['noMinPattern'], basename($file))) {
$spec['minifier'] = '';
}
return new Minify_Source($spec);
}
} }

View File

@@ -40,10 +40,16 @@ class Minify_Lines {
? $options['id'] ? $options['id']
: ''; : '';
$content = str_replace("\r\n", "\n", $content); $content = str_replace("\r\n", "\n", $content);
// Hackily rewrite strings with XPath expressions that are
// likely to throw off our dumb parser (for Prototype 1.6.1).
$content = str_replace('"/*"', '"/"+"*"', $content);
$content = preg_replace('@([\'"])(\\.?//?)\\*@', '$1$2$1+$1*', $content);
$lines = explode("\n", $content); $lines = explode("\n", $content);
$numLines = count($lines); $numLines = count($lines);
// determine left padding // determine left padding
$padTo = strlen($numLines); $padTo = strlen((string) $numLines); // e.g. 103 lines = 3 digits
$inComment = false; $inComment = false;
$i = 0; $i = 0;
$newLines = array(); $newLines = array();

View File

@@ -128,11 +128,14 @@ class Minify_YUICompressor {
private static function _prepare() private static function _prepare()
{ {
if (! is_file(self::$jarFile) if (! is_file(self::$jarFile)) {
|| ! is_dir(self::$tempDir) throw new Exception('Minify_YUICompressor : $jarFile('.self::$jarFile.') is not a valid file.');
|| ! is_writable(self::$tempDir) }
) { if (! is_dir(self::$tempDir)) {
throw new Exception('Minify_YUICompressor : $jarFile and $tempDir must be set.'); throw new Exception('Minify_YUICompressor : $tempDir('.self::$tempDir.') is not a valid direcotry.');
}
if (! is_writable(self::$tempDir)) {
throw new Exception('Minify_YUICompressor : $tempDir('.self::$tempDir.') is not writable.');
} }
} }
} }

View File

@@ -25,7 +25,7 @@ p{padding:0px;margin:0px;padding-bottom:5px}#post_nav{text-align:left;padding-bo
a{text-decoration:none;font-family:Verdana;font-size:12px;color:#108eed}#post_nav a:hover, .post_nav_2 p a:hover{text-decoration:underline;color:#FF8000}#rightcol a{text-decoration:none;font-family:Verdana;font-size:12px;color:#108eed}#post_nav a:hover, .post_nav_2 p a:hover{text-decoration:underline;color:#FF8000}#rightcol
#about{padding-bottom:10px}#rightcol #r_news #about{padding-bottom:10px}#rightcol #r_news
input{color:#333;font-size:12px}#header{height:200px;width:100%;background-image:url('images/header_bg.jpg');background-repeat:x-repeat}#header input{color:#333;font-size:12px}#header{height:200px;width:100%;background-image:url('images/header_bg.jpg');background-repeat:x-repeat}#header
img{float:right;margin-right: -3px;z-index:100}.tags{text-transform:lowercase;color:#333;font-family:arial;font-size:12px;border-top:2px dotted #EEE;width:300px;padding-top:20px;padding-bottom:0px;margin-top:0px;padding-left:20px;padding-right:20px}.tags img{float:right;margin-right:-3px;z-index:100}.tags{text-transform:lowercase;color:#333;font-family:arial;font-size:12px;border-top:2px dotted #EEE;width:300px;padding-top:20px;padding-bottom:0px;margin-top:0px;padding-left:20px;padding-right:20px}.tags
a{color:#108eed}.tags a{color:#108eed}.tags
p{text-align:left;margin:0px;padding:0px}blockquote p{text-align:left;margin:0px;padding:0px}blockquote
strong{font-family:verdana;display:block;margin-top:10px;color:#F00;font-style:italic;text-align:right}blockquote{margin:0px;background-color:#eee;border:2px strong{font-family:verdana;display:block;margin-top:10px;color:#F00;font-style:italic;text-align:right}blockquote{margin:0px;background-color:#eee;border:2px

View File

@@ -0,0 +1,3 @@
// The MinApp controller should cause this file to not be minified
// since the basename of the filepath matches the default noMinPattern

View File

@@ -1 +1,2 @@
// JSMin should not alter this file
if(!a.id)a.id="dp"+ ++this.uuid; if(!a.id)a.id="dp"+ ++this.uuid;

View File

@@ -1 +1,2 @@
// JSMin should not alter this file
if(!a.id)a.id="dp"+ ++this.uuid; if(!a.id)a.id="dp"+ ++this.uuid;

View File

@@ -0,0 +1,6 @@
/*
* This file is to intentionally throw a JSMin exception
*/
function HelloWorld() {
return /regexp;
}

View File

@@ -1,2 +1,10 @@
var triggerBug = {_default: "*/*"}; // sections from Prototype 1.6.1
var essentialFunctionality = true; var xpath = ".//*[local-name()='ul' or local-name()='UL']" +
"//*[local-name()='li' or local-name()='LI']";
this.matcher = ['.//*'];
xpath = {
descendant: "//*",
child: "/*",
f: 0
};
document._getElementsByXPath('.//*' + cond, element);

View File

@@ -29,9 +29,16 @@
; ;
/* lines_bugs.js */ /* lines_bugs.js */
/* 1 */ var triggerBug = {_default: "*/*"}; /* 1 */ // sections from Prototype 1.6.1
/* 2 */ var essentialFunctionality = true; /* 2 */ var xpath = ".//"+"*[local-name()='ul' or local-name()='UL']" +
/* 3 */ /* 3 */ "//"+"*[local-name()='li' or local-name()='LI']";
/* 4 */ this.matcher = ['.//'+'*'];
/* 5 */ xpath = {
/* 6 */ descendant: "//"+"*",
/* 7 */ child: "/"+"*",
/* 8 */ f: 0
/* 9 */ };
/* 10 */ document._getElementsByXPath('.//'+'*' + cond, element);
; ;
/* QueryString.js */ /* QueryString.js */

View File

@@ -1,5 +1,6 @@
(function(){var (function(){var
reMailto=/^mailto:my_name_is_(\S+)_and_the_domain_is_(\S+)$/,reRemoveTitleIf=/^my name is/,oo=window.onload,fixHrefs=function(){var i=0,l,m;while(l=document.links[i++]){if(m=l.href.match(reMailto)){l.href='mailto:'+m[1]+'@'+m[2];if(reRemoveTitleIf.test(l.title)){l.title='';}}}};window.onload=function(){oo&&oo();fixHrefs();};})();;var MrClay=window.MrClay||{};MrClay.QueryString=function(){var parse=function(str){var assignments=str.split('&'),obj={},propValue;for(var i=0,l=assignments.length;i<l;++i){propValue=assignments[i].split('=');if(propValue.length>2||-1!=propValue[0].indexOf('+')||propValue[0]==''){continue;} reMailto=/^mailto:my_name_is_(\S+)_and_the_domain_is_(\S+)$/,reRemoveTitleIf=/^my name is/,oo=window.onload,fixHrefs=function(){var i=0,l,m;while(l=document.links[i++]){if(m=l.href.match(reMailto)){l.href='mailto:'+m[1]+'@'+m[2];if(reRemoveTitleIf.test(l.title)){l.title='';}}}};window.onload=function(){oo&&oo();fixHrefs();};})();
;var MrClay=window.MrClay||{};MrClay.QueryString=function(){var parse=function(str){var assignments=str.split('&'),obj={},propValue;for(var i=0,l=assignments.length;i<l;++i){propValue=assignments[i].split('=');if(propValue.length>2||-1!=propValue[0].indexOf('+')||propValue[0]==''){continue;}
if(propValue.length==1){propValue[1]=propValue[0];} if(propValue.length==1){propValue[1]=propValue[0];}
obj[unescape(propValue[0])]=unescape(propValue[1].replace(/\+/g,' '));} obj[unescape(propValue[0])]=unescape(propValue[1].replace(/\+/g,' '));}
return obj;};function construct_(spec){spec=spec||window;if(typeof spec=='object'){this.window=spec;spec=spec.location.search.substr(1);}else{this.window=window;} return obj;};function construct_(spec){spec=spec||window;if(typeof spec=='object'){this.window=spec;spec=spec.location.search.substr(1);}else{this.window=window;}

View File

@@ -129,13 +129,18 @@ function test_HTTP_Encoder()
} }
} }
HTTP_Encoder::$encodeToIe6 = true;
$_SERVER['HTTP_ACCEPT_ENCODING'] = 'identity'; $_SERVER['HTTP_ACCEPT_ENCODING'] = 'identity';
$he = new HTTP_Encoder(array( $he = new HTTP_Encoder(array('content' => 'Hello'));
'content' => 'Hello'
));
$he->encode(); $he->encode();
$headers = $he->getHeaders(); $headers = $he->getHeaders();
assertTrue(isset($headers['Vary']), 'HTTP_Encoder : Vary always sent'); assertTrue(isset($headers['Vary']), 'HTTP_Encoder : Vary always sent to good browsers');
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
$he = new HTTP_Encoder(array('content' => 'Hello'));
$he->encode();
$headers = $he->getHeaders();
assertTrue(! isset($headers['Vary']), 'HTTP_Encoder : Vary not sent to bad IE (Issue 126)');
} }
test_HTTP_Encoder(); test_HTTP_Encoder();

View File

@@ -40,15 +40,15 @@ function test_JSMin()
test_JSMin_exception('"Hello' test_JSMin_exception('"Hello'
,'Unterminated String' ,'Unterminated String'
,'JSMin_UnterminatedStringException' ,'JSMin_UnterminatedStringException'
,"Unterminated String: '\"Hello'"); ,"Unterminated String: \"Hello");
test_JSMin_exception("return /regexp\n}" test_JSMin_exception("return /regexp\n}"
,'Unterminated RegExp' ,'Unterminated RegExp'
,'JSMin_UnterminatedRegExpException' ,'JSMin_UnterminatedRegExpException'
,"Unterminated RegExp: '/regexp\n'"); ,"Unterminated RegExp: /regexp\n");
test_JSMin_exception("/* Comment " test_JSMin_exception("/* Comment "
,'Unterminated Comment' ,'Unterminated Comment'
,'JSMin_UnterminatedCommentException' ,'JSMin_UnterminatedCommentException'
,"Unterminated Comment: '/* Comment '"); ,"Unterminated Comment: /* Comment ");
} }
} }

View File

@@ -53,7 +53,7 @@ function test_Minify()
,'Minify : cache, and minifier classes aren\'t loaded for 304s' ,'Minify : cache, and minifier classes aren\'t loaded for 304s'
); );
// Test minifying JS and serving with Expires header // Test JS and Expires
$content = preg_replace('/\\r\\n?/', "\n", file_get_contents($minifyTestPath . '/minified.js')); $content = preg_replace('/\\r\\n?/', "\n", file_get_contents($minifyTestPath . '/minified.js'));
$lastModified = max( $lastModified = max(
@@ -96,7 +96,7 @@ function test_Minify()
// test for Issue 73 // test for Issue 73
Minify::setCache(null); Minify::setCache(null);
$expected = ";function h(){}"; $expected = "\n;function h(){}";
$output = Minify::serve('Files', array( $output = Minify::serve('Files', array(
'files' => array( 'files' => array(
$minifyTestPath . '/issue73_1.js' $minifyTestPath . '/issue73_1.js'

View File

@@ -79,7 +79,8 @@ function test_environment()
break; break;
} }
} }
if ($passed && stream_get_contents($fp) !== 'World!') { $streamContents = stream_get_contents($fp);
if ($passed && $streamContents !== 'World!') {
$passed = false; $passed = false;
} }
assertTrue( assertTrue(