Skip to content
Permalink
Browse files

Fixing include errors caused by empty asset filters in Dispatcher::as…

…set(). Fixes #313
  • Loading branch information...
markstory committed Feb 7, 2010
1 parent e6404f2 commit 1febd776bd6afe2139a86a6019543de555fff49d
Showing with 31 additions and 5 deletions.
  1. +11 −5 cake/dispatcher.php
  2. +20 −0 cake/tests/cases/dispatcher.test.php
@@ -596,12 +596,18 @@ function asset($url) {
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
return false;
}
if (strpos($url, 'ccss/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.css');
$filters = Configure::read('Asset.filter');
$isCss = strpos($url, 'ccss/') === 0;
$isJs = strpos($url, 'cjs/') === 0;
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;
@@ -1974,6 +1974,26 @@ function testAssets() {
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
*

0 comments on commit 1febd77

Please sign in to comment.
You can’t perform that action at this time.