Fixing include errors caused by empty asset filters in Dispatcher::asset(). Fixes #313

This commit is contained in:
Mark Story 2010-02-07 15:19:47 -05:00
parent e6404f2d06
commit 1febd776bd
2 changed files with 30 additions and 4 deletions

View file

@ -596,12 +596,18 @@ class Dispatcher extends Object {
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
return false;
}
$filters = Configure::read('Asset.filter');
$isCss = strpos($url, 'ccss/') === 0;
$isJs = strpos($url, 'cjs/') === 0;
if (strpos($url, 'ccss/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.css');
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
header('HTTP/1.1 404 Not Found');
return $this->_stop();
} elseif ($isCss) {
include WWW_ROOT . DS . $filter['css'];
$this->_stop();
} elseif (strpos($url, 'cjs/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.js');
} elseif ($isJs) {
include WWW_ROOT . DS . $filters['js'];
$this->_stop();
}
$controller = null;

View file

@ -1974,6 +1974,26 @@ class DispatcherTest extends CakeTestCase {
header('Content-type: text/html');
}
/**
* test that missing asset processors trigger a 404 with no response body.
*
* @return void
*/
function testMissingAssetProcessor404() {
$Dispatcher =& new TestDispatcher();
Configure::write('Asset.filter', array(
'js' => '',
'css' => null
));
$this->assertNoErrors();
$Dispatcher->params = $Dispatcher->parseParams('ccss/cake.generic.css');
ob_start();
$Dispatcher->asset('ccss/cake.generic.css');
header('HTTP/1.1 200 Ok');
}
/**
* testFullPageCachingDispatch method
*