mirror of
https://github.com/mrclay/minify.git
synced 2025-08-16 11:03:59 +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:
@@ -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);
|
@@ -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(
|
||||||
|
@@ -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';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -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')
|
|
||||||
))
|
|
||||||
),//*/
|
|
||||||
);
|
);
|
@@ -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;
|
||||||
@@ -63,4 +67,4 @@ if (isset($_GET['f']) || isset($_GET['g'])) {
|
|||||||
} else {
|
} else {
|
||||||
header("Location: /");
|
header("Location: /");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
@@ -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);
|
||||||
|
@@ -33,11 +33,11 @@
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* For more control over headers, use getHeaders() and getData() and send your
|
* For more control over headers, use getHeaders() and getData() and send your
|
||||||
* own output.
|
* own output.
|
||||||
*
|
*
|
||||||
* Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate,
|
* Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate,
|
||||||
* and gzcompress functions for gzip, deflate, and compress-encoding
|
* and gzcompress functions for gzip, deflate, and compress-encoding
|
||||||
* respectively.
|
* respectively.
|
||||||
*
|
*
|
||||||
* @package Minify
|
* @package Minify
|
||||||
* @subpackage HTTP
|
* @subpackage HTTP
|
||||||
@@ -59,7 +59,7 @@ class HTTP_Encoder {
|
|||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public static $encodeToIe6 = false;
|
public static $encodeToIe6 = true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +88,7 @@ class HTTP_Encoder {
|
|||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function __construct($spec)
|
public function __construct($spec)
|
||||||
{
|
{
|
||||||
$this->_content = $spec['content'];
|
$this->_content = $spec['content'];
|
||||||
$this->_headers['Content-Length'] = (string)strlen($this->_content);
|
$this->_headers['Content-Length'] = (string)strlen($this->_content);
|
||||||
@@ -111,7 +111,7 @@ class HTTP_Encoder {
|
|||||||
*
|
*
|
||||||
* return string
|
* return string
|
||||||
*/
|
*/
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
return $this->_content;
|
return $this->_content;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ class HTTP_Encoder {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getHeaders()
|
public function getHeaders()
|
||||||
{
|
{
|
||||||
return $this->_headers;
|
return $this->_headers;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ class HTTP_Encoder {
|
|||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function sendHeaders()
|
public function sendHeaders()
|
||||||
{
|
{
|
||||||
foreach ($this->_headers as $name => $val) {
|
foreach ($this->_headers as $name => $val) {
|
||||||
header($name . ': ' . $val);
|
header($name . ': ' . $val);
|
||||||
@@ -164,7 +164,7 @@ class HTTP_Encoder {
|
|||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function sendAll()
|
public function sendAll()
|
||||||
{
|
{
|
||||||
$this->sendHeaders();
|
$this->sendHeaders();
|
||||||
echo $this->_content;
|
echo $this->_content;
|
||||||
@@ -181,21 +181,21 @@ class HTTP_Encoder {
|
|||||||
* be non 0. The methods are favored in order of gzip, deflate, then
|
* be non 0. The methods are favored in order of gzip, deflate, then
|
||||||
* compress. Deflate is always smallest and generally faster, but is
|
* compress. Deflate is always smallest and generally faster, but is
|
||||||
* rarely sent by servers, so client support could be buggier.
|
* rarely sent by servers, so client support could be buggier.
|
||||||
*
|
*
|
||||||
* @param bool $allowCompress allow the older compress encoding
|
* @param bool $allowCompress allow the older compress encoding
|
||||||
*
|
*
|
||||||
* @param bool $allowDeflate allow the more recent deflate encoding
|
* @param bool $allowDeflate allow the more recent deflate encoding
|
||||||
*
|
*
|
||||||
* @return array two values, 1st is the actual encoding method, 2nd is the
|
* @return array two values, 1st is the actual encoding method, 2nd is the
|
||||||
* alias of that method to use in the Content-Encoding header (some browsers
|
* alias of that method to use in the Content-Encoding header (some browsers
|
||||||
* call gzip "x-gzip" etc.)
|
* call gzip "x-gzip" etc.)
|
||||||
*/
|
*/
|
||||||
public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)
|
public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)
|
||||||
{
|
{
|
||||||
// @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('', '');
|
||||||
}
|
}
|
||||||
@@ -244,16 +244,18 @@ class HTTP_Encoder {
|
|||||||
* this fails, false is returned.
|
* this fails, false is returned.
|
||||||
*
|
*
|
||||||
* The header "Vary: Accept-Encoding" is added. If encoding is successful,
|
* The header "Vary: Accept-Encoding" is added. If encoding is successful,
|
||||||
* the Content-Length header is updated, and Content-Encoding is also added.
|
* the Content-Length header is updated, and Content-Encoding is also added.
|
||||||
*
|
*
|
||||||
* @param int $compressionLevel given to zlib functions. If not given, the
|
* @param int $compressionLevel given to zlib functions. If not given, the
|
||||||
* class default will be used.
|
* class default will be used.
|
||||||
*
|
*
|
||||||
* @return bool success true if the content was actually compressed
|
* @return bool success true if the content was actually compressed
|
||||||
*/
|
*/
|
||||||
public function encode($compressionLevel = null)
|
public function encode($compressionLevel = null)
|
||||||
{
|
{
|
||||||
$this->_headers['Vary'] = 'Accept-Encoding';
|
if (! self::isBuggyIe()) {
|
||||||
|
$this->_headers['Vary'] = 'Accept-Encoding';
|
||||||
|
}
|
||||||
if (null === $compressionLevel) {
|
if (null === $compressionLevel) {
|
||||||
$compressionLevel = self::$compressionLevel;
|
$compressionLevel = self::$compressionLevel;
|
||||||
}
|
}
|
||||||
@@ -262,9 +264,9 @@ class HTTP_Encoder {
|
|||||||
|| !extension_loaded('zlib'))
|
|| !extension_loaded('zlib'))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($this->_encodeMethod[0] === 'deflate') {
|
if ($this->_encodeMethod[0] === 'deflate') {
|
||||||
$encoded = gzdeflate($this->_content, $compressionLevel);
|
$encoded = gzdeflate($this->_content, $compressionLevel);
|
||||||
} elseif ($this->_encodeMethod[0] === 'gzip') {
|
} elseif ($this->_encodeMethod[0] === 'gzip') {
|
||||||
$encoded = gzencode($this->_content, $compressionLevel);
|
$encoded = gzencode($this->_content, $compressionLevel);
|
||||||
} else {
|
} else {
|
||||||
@@ -285,7 +287,7 @@ class HTTP_Encoder {
|
|||||||
* This is a convenience method for common use of the class
|
* This is a convenience method for common use of the class
|
||||||
*
|
*
|
||||||
* @param string $content
|
* @param string $content
|
||||||
*
|
*
|
||||||
* @param int $compressionLevel given to zlib functions. If not given, the
|
* @param int $compressionLevel given to zlib functions. If not given, the
|
||||||
* class default will be used.
|
* class default will be used.
|
||||||
*
|
*
|
||||||
@@ -296,20 +298,18 @@ class HTTP_Encoder {
|
|||||||
if (null === $compressionLevel) {
|
if (null === $compressionLevel) {
|
||||||
$compressionLevel = self::$compressionLevel;
|
$compressionLevel = self::$compressionLevel;
|
||||||
}
|
}
|
||||||
$he = new HTTP_Encoder(array('content' => $content));
|
$he = new HTTP_Encoder(array('content' => $content));
|
||||||
$ret = $he->encode($compressionLevel);
|
$ret = $he->encode($compressionLevel);
|
||||||
$he->sendAll();
|
$he->sendAll();
|
||||||
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
|
||||||
@@ -318,9 +318,13 @@ class HTTP_Encoder {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// no regex = faaast
|
// no regex = faaast
|
||||||
$version = (float)substr($ua, 30);
|
$version = (float)substr($ua, 30);
|
||||||
return self::$encodeToIe6
|
return self::$encodeToIe6
|
||||||
? ($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('', '');
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
$content = self::_combineMinify();
|
try {
|
||||||
|
$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;
|
||||||
$content = self::_combineMinify();
|
try {
|
||||||
|
$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,37 +475,26 @@ 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) {
|
foreach (self::$_controller->sources as $source) {
|
||||||
|
// allow the source to override our minifier and options
|
||||||
|
$minifier = (null !== $source->minifier)
|
||||||
|
? $source->minifier
|
||||||
|
: $defaultMinifier;
|
||||||
|
$options = (null !== $source->minifyOptions)
|
||||||
|
? array_merge($defaultOptions, $source->minifyOptions)
|
||||||
|
: $defaultOptions;
|
||||||
|
if ($minifier) {
|
||||||
|
self::$_controller->loadMinifier($minifier);
|
||||||
|
// get source content and minify it
|
||||||
|
$pieces[] = call_user_func($minifier, $source->getContent(), $options);
|
||||||
|
} else {
|
||||||
$pieces[] = $source->getContent();
|
$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) {
|
|
||||||
// allow the source to override our minifier and options
|
|
||||||
$minifier = (null !== $source->minifier)
|
|
||||||
? $source->minifier
|
|
||||||
: $defaultMinifier;
|
|
||||||
$options = (null !== $source->minifyOptions)
|
|
||||||
? array_merge($defaultOptions, $source->minifyOptions)
|
|
||||||
: $defaultOptions;
|
|
||||||
if ($minifier) {
|
|
||||||
self::$_controller->loadMinifier($minifier);
|
|
||||||
// get source content and minify it
|
|
||||||
$pieces[] = call_user_func($minifier, $source->getContent(), $options);
|
|
||||||
} else {
|
|
||||||
$pieces[] = $source->getContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$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);
|
||||||
@@ -512,7 +536,7 @@ class Minify {
|
|||||||
{
|
{
|
||||||
if (self::$_options['bubbleCssImports']) {
|
if (self::$_options['bubbleCssImports']) {
|
||||||
// bubble CSS imports
|
// bubble CSS imports
|
||||||
preg_match_all('/@import.*?;/', $css, $imports);
|
preg_match_all('/@import.*?;/', $css, $imports);
|
||||||
$css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);
|
$css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);
|
||||||
} else if ('' !== self::$importWarning) {
|
} else if ('' !== self::$importWarning) {
|
||||||
// remove comments so we don't mistake { in a comment as a block
|
// remove comments so we don't mistake { in a comment as a block
|
||||||
|
@@ -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
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,9 +26,9 @@ class Minify_Lines {
|
|||||||
*
|
*
|
||||||
* 'id': (optional) string to identify file. E.g. file name/path
|
* 'id': (optional) string to identify file. E.g. file name/path
|
||||||
*
|
*
|
||||||
* 'currentDir': (default null) if given, this is assumed to be the
|
* 'currentDir': (default null) if given, this is assumed to be the
|
||||||
* directory of the current CSS file. Using this, minify will rewrite
|
* directory of the current CSS file. Using this, minify will rewrite
|
||||||
* all relative URIs in import/url declarations to correctly point to
|
* all relative URIs in import/url declarations to correctly point to
|
||||||
* the desired files, and prepend a comment with debugging information about
|
* the desired files, and prepend a comment with debugging information about
|
||||||
* this process.
|
* this process.
|
||||||
*
|
*
|
||||||
@@ -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();
|
||||||
@@ -64,7 +70,7 @@ class Minify_Lines {
|
|||||||
$content = Minify_CSS_UriRewriter::rewrite(
|
$content = Minify_CSS_UriRewriter::rewrite(
|
||||||
$content
|
$content
|
||||||
,$options['currentDir']
|
,$options['currentDir']
|
||||||
,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']
|
,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']
|
||||||
,isset($options['symlinks']) ? $options['symlinks'] : array()
|
,isset($options['symlinks']) ? $options['symlinks'] : array()
|
||||||
);
|
);
|
||||||
$content = "/* Minify_CSS_UriRewriter::\$debugText\n\n"
|
$content = "/* Minify_CSS_UriRewriter::\$debugText\n\n"
|
||||||
@@ -82,7 +88,7 @@ class Minify_Lines {
|
|||||||
*
|
*
|
||||||
* @param bool $inComment was the parser in a comment at the
|
* @param bool $inComment was the parser in a comment at the
|
||||||
* beginning of the line?
|
* beginning of the line?
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function _eolInComment($line, $inComment)
|
private static function _eolInComment($line, $inComment)
|
||||||
|
@@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
|
3
min_unit_tests/_test_files/js/issue141.min.js
vendored
Normal file
3
min_unit_tests/_test_files/js/issue141.min.js
vendored
Normal 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
|
||||||
|
|
@@ -1 +1,2 @@
|
|||||||
if(!a.id)a.id="dp"+ ++this.uuid;
|
// JSMin should not alter this file
|
||||||
|
if(!a.id)a.id="dp"+ ++this.uuid;
|
||||||
|
@@ -1 +1,2 @@
|
|||||||
if(!a.id)a.id="dp"+ ++this.uuid;
|
// JSMin should not alter this file
|
||||||
|
if(!a.id)a.id="dp"+ ++this.uuid;
|
||||||
|
6
min_unit_tests/_test_files/minify/issue143.js
Normal file
6
min_unit_tests/_test_files/minify/issue143.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* This file is to intentionally throw a JSMin exception
|
||||||
|
*/
|
||||||
|
function HelloWorld() {
|
||||||
|
return /regexp;
|
||||||
|
}
|
@@ -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);
|
@@ -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 */
|
||||||
|
@@ -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;}
|
||||||
|
@@ -128,14 +128,19 @@ function test_HTTP_Encoder()
|
|||||||
, "(off by ". abs($ret - $test['exp']) . " bytes)\n\n";
|
, "(off by ". abs($ret - $test['exp']) . " bytes)\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
@@ -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 ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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'
|
||||||
|
@@ -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(
|
||||||
|
Reference in New Issue
Block a user