mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing include errors caused by empty asset filters in Dispatcher::asset(). Fixes #313
This commit is contained in:
parent
e6404f2d06
commit
1febd776bd
2 changed files with 30 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue