mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-07 12:02:41 +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) {
|
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$filters = Configure::read('Asset.filter');
|
||||||
|
$isCss = strpos($url, 'ccss/') === 0;
|
||||||
|
$isJs = strpos($url, 'cjs/') === 0;
|
||||||
|
|
||||||
if (strpos($url, 'ccss/') === 0) {
|
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
|
||||||
include WWW_ROOT . DS . Configure::read('Asset.filter.css');
|
header('HTTP/1.1 404 Not Found');
|
||||||
|
return $this->_stop();
|
||||||
|
} elseif ($isCss) {
|
||||||
|
include WWW_ROOT . DS . $filter['css'];
|
||||||
$this->_stop();
|
$this->_stop();
|
||||||
} elseif (strpos($url, 'cjs/') === 0) {
|
} elseif ($isJs) {
|
||||||
include WWW_ROOT . DS . Configure::read('Asset.filter.js');
|
include WWW_ROOT . DS . $filters['js'];
|
||||||
$this->_stop();
|
$this->_stop();
|
||||||
}
|
}
|
||||||
$controller = null;
|
$controller = null;
|
||||||
|
|
|
@ -1974,6 +1974,26 @@ class DispatcherTest extends CakeTestCase {
|
||||||
header('Content-type: text/html');
|
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
|
* testFullPageCachingDispatch method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue