Navigation Menu

Skip to content

Commit

Permalink
Fixing include errors caused by empty asset filters in Dispatcher::as…
Browse files Browse the repository at this point in the history
…set(). Fixes #313
  • Loading branch information
markstory committed Feb 7, 2010
1 parent e6404f2 commit 1febd77
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cake/dispatcher.php
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions cake/tests/cases/dispatcher.test.php
Expand Up @@ -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
*
Expand Down

0 comments on commit 1febd77

Please sign in to comment.