Adding fix for undefined notice in vendors.php

Removed check for required file in Cache::!__loadEngine();
Fixed cache being wrote on each request from Configure::listObjects(); when data was an empty array
Removed extra call to App::getInstance(); in App::import();
Moved setting of App::!__loaded; inside of if statement.
Removed cake core install directory paths from the cached dir_map.
Changed uses('file'); to require statement in file.php
Changed uses('set'); to require statement in inflector.php
Removed check for existing inflections.php since this file has been included in 1.2 since Dev releases.
Added additional test for Helper::clean();
Fixed bug in Helper::!__clean();
Fixed random output of 1 when using MediaView;
Added csv mime type to MediaView



git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7516 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-08-27 03:42:17 +00:00
parent 7fe1a03fda
commit 80fa429785
9 changed files with 78 additions and 75 deletions

View file

@ -30,14 +30,15 @@
/**
* Enter description here...
*/
$file = $_GET['file'];
$pos = strpos($file, '..');
if ($pos === false) {
if (is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file)))
{
readfile('../../vendors/javascript/'.$file);
if (isset($_GET['file'])) {
$file = $_GET['file'];
$pos = strpos($file, '..');
if ($pos === false) {
if (is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file))) {
readfile('../../vendors/javascript/'.$file);
return;
}
}
} else {
header('HTTP/1.1 404 Not Found');
}
header('HTTP/1.1 404 Not Found');
?>

View file

@ -85,10 +85,7 @@ class Cache extends Object {
*/
function __loadEngine($name) {
if (!class_exists($name . 'Engine')) {
$fileName = LIBS . DS . 'cache' . DS . strtolower($name) . '.php';
if (!require($fileName)) {
return false;
}
require LIBS . DS . 'cache' . DS . strtolower($name) . '.php';
}
return true;
}

View file

@ -189,14 +189,13 @@ class Configure extends Object {
if ($type !== 'file') {
$objects = array_map(array(&$Inflector, 'camelize'), $objects);
}
if ($cache === true) {
if ($cache === true && !empty($objects)) {
$_this->__objects[$name] = $objects;
$_this->__cache = true;
} else {
return $objects;
}
}
return $_this->__objects[$name];
}
/**
@ -792,7 +791,6 @@ class App extends Object {
if ($name != null && strpos($name, '.') !== false) {
list($plugin, $name) = explode('.', $name);
}
$_this =& App::getInstance();
$_this->return = $return;
if (isset($ext)) {
@ -936,8 +934,8 @@ class App extends Object {
if (file_exists($file)) {
if (!$_this->return) {
require($file);
$_this->__loaded[$file] = true;
}
$_this->__loaded[$file] = true;
return true;
}
return false;
@ -1015,8 +1013,6 @@ class App extends Object {
* @access private
*/
function __settings($type, $plugin, $parent) {
$_this = & App::getInstance();
if (!$parent) {
return null;
}
@ -1027,6 +1023,7 @@ class App extends Object {
}
$path = null;
$load = strtolower($type);
$_this = & App::getInstance();
switch ($load) {
case 'model':
@ -1148,11 +1145,12 @@ class App extends Object {
*/
function __destruct() {
$_this = & App::getInstance();
if ($_this->__cache) {
$core = Configure::corePaths('cake');
unset($_this->__paths[rtrim($core[0], DS)]);
Cache::write('dir_map', array_filter($_this->__paths), '_cake_core_');
Cache::write('file_map', array_filter($_this->__map), '_cake_core_');
}
}
}
?>
?>

View file

@ -33,7 +33,7 @@ if (!class_exists('Object')) {
}
if (!class_exists('Folder')) {
uses('folder');
require LIBS . 'folder.php';
}
/**
* Convenience class for reading, writing and appending to files.

View file

@ -34,7 +34,7 @@ if (!class_exists('Object')) {
uses('object');
}
if (!class_exists('Set')) {
uses('set');
require LIBS . 'set.php';
}
/**
* Pluralize and singularize English words.
@ -147,12 +147,11 @@ class Inflector extends Object {
$uninflected = $coreUninflectedPlural;
$irregular = $coreIrregularPlural;
if (file_exists(CONFIGS . 'inflections.php')) {
include(CONFIGS.'inflections.php');
$pluralRules = Set::pushDiff($pluralRules, $corePluralRules);
$uninflected = Set::pushDiff($uninflectedPlural, $coreUninflectedPlural);
$irregular = Set::pushDiff($irregularPlural, $coreIrregularPlural);
}
include(CONFIGS.'inflections.php');
$pluralRules = Set::pushDiff($pluralRules, $corePluralRules);
$uninflected = Set::pushDiff($uninflectedPlural, $coreUninflectedPlural);
$irregular = Set::pushDiff($irregularPlural, $coreIrregularPlural);
$_this->pluralRules = array('pluralRules' => $pluralRules, 'uninflected' => $uninflected, 'irregular' => $irregular);
$_this->pluralized = array();
}
@ -290,12 +289,11 @@ class Inflector extends Object {
$uninflected = $coreUninflectedSingular;
$irregular = $coreIrregularSingular;
if (file_exists(CONFIGS . 'inflections.php')) {
include(CONFIGS.'inflections.php');
$singularRules = Set::pushDiff($singularRules, $coreSingularRules);
$uninflected = Set::pushDiff($uninflectedSingular, $coreUninflectedSingular);
$irregular = Set::pushDiff($irregularSingular, $coreIrregularSingular);
}
include(CONFIGS.'inflections.php');
$singularRules = Set::pushDiff($singularRules, $coreSingularRules);
$uninflected = Set::pushDiff($uninflectedSingular, $coreUninflectedSingular);
$irregular = Set::pushDiff($irregularSingular, $coreIrregularSingular);
$_this->singularRules = array('singularRules' => $singularRules, 'uninflected' => $uninflected, 'irregular' => $irregular);
$_this->singularized = array();
}
@ -429,7 +427,7 @@ class Inflector extends Object {
* @static
*/
function slug($string, $replacement = '_') {
if(!class_exists('String')) {
if (!class_exists('String')) {
require_once LIBS . 'string.php';
}
$map = array(

View file

@ -718,22 +718,24 @@ class Helper extends Overloadable {
$this->__cleaned = $this->__tainted;
}
$this->__cleaned = str_replace(array("&","<",">"),array("&","<",">"), $this->__cleaned);
$this->__cleaned = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u',"$1;", $this->__cleaned);
$this->__cleaned = preg_replace('#(&\#x*)([0-9A-F]+);*#iu',"$1$2;", $this->__cleaned);
$this->__cleaned = str_replace(array("&", "<", ">"), array("&", "<", ">"), $this->__cleaned);
$this->__cleaned = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u', "$1;", $this->__cleaned);
$this->__cleaned = preg_replace('#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $this->__cleaned);
$this->__cleaned = html_entity_decode($this->__cleaned, ENT_COMPAT, "UTF-8");
$this->__cleaned = preg_replace('#(<*[^>]*[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu',"$1>", $this->__cleaned);
$this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2nojavascript...', $this->__cleaned);
$this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2novbscript...', $this->__cleaned);
$this->__cleaned = preg_replace('#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>#iUu', "$1>", $this->__cleaned);
$this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2nojavascript...', $this->__cleaned);
$this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2novbscript...', $this->__cleaned);
$this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=*([\'\"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#iUu','$1=$2nomozbinding...', $this->__cleaned);
$this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',"$1>", $this->__cleaned);
$this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU',"$1>", $this->__cleaned);
$this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu',"$1>",$this->__cleaned);
$this->__cleaned = preg_replace('#</*\w+:\w[^>]*>#i',"", $this->__cleaned);
$this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*data[\x00-\x20]*:#Uu', '$1=$2nodata...', $this->__cleaned);
$this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU', "$1>", $this->__cleaned);
$this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU', "$1>", $this->__cleaned);
$this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu', "$1>", $this->__cleaned);
$this->__cleaned = preg_replace('#</*\w+:\w[^>]*>#i', "", $this->__cleaned);
do {
$oldstring = $this->__cleaned;
$this->__cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i',"",$this->__cleaned);
$this->__cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->__cleaned);
} while ($oldstring != $this->__cleaned);
$this->__cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->__cleaned);
}
}
?>

View file

@ -35,9 +35,9 @@ class MediaView extends View {
var $mimeType = array('ai' => 'application/postscript', 'bcpio' => 'application/x-bcpio', 'bin' => 'application/octet-stream',
'ccad' => 'application/clariscad', 'cdf' => 'application/x-netcdf', 'class' => 'application/octet-stream',
'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh',
'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dms' => 'application/octet-stream',
'doc' => 'application/msword', 'drw' => 'application/drafting', 'dvi' => 'application/x-dvi',
'dwg' => 'application/acad', 'dxf' => 'application/dxf', 'dxr' => 'application/x-director',
'csv' => 'application/csv', 'dcr' => 'application/x-director', 'dir' => 'application/x-director',
'dms' => 'application/octet-stream', 'doc' => 'application/msword', 'drw' => 'application/drafting',
'dvi' => 'application/x-dvi', 'dwg' => 'application/acad', 'dxf' => 'application/dxf', 'dxr' => 'application/x-director',
'eps' => 'application/postscript', 'exe' => 'application/octet-stream', 'ez' => 'application/andrew-inset',
'flv' => 'video/x-flv', 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'hdf' => 'application/x-hdf',
'hqx' => 'application/mac-binhex40', 'ips' => 'application/x-ipscript', 'ipx' => 'application/x-ipix',
@ -177,7 +177,9 @@ class MediaView extends View {
@ob_flush();
}
fclose($handle);
return((connection_status() == 0) && !connection_aborted());
if (connection_status() == 0 && !connection_aborted) {
return true;
}
}
return false;
}

View file

@ -29,21 +29,21 @@
App::import('Core', array('View', 'Helper'));
/**
* HelperTestPost class
*
*
* @package cake
* @subpackage cake.tests.cases.libs.view
*/
class HelperTestPost extends Model {
/**
* useTable property
*
*
* @var bool false
* @access public
*/
var $useTable = false;
/**
* schema method
*
*
* @access public
* @return void
*/
@ -61,7 +61,7 @@ class HelperTestPost extends Model {
}
/**
* hasAndBelongsToMany property
*
*
* @var array
* @access public
*/
@ -70,21 +70,21 @@ class HelperTestPost extends Model {
/**
* HelperTestComment class
*
*
* @package cake
* @subpackage cake.tests.cases.libs.view
*/
class HelperTestComment extends Model {
/**
* useTable property
*
*
* @var bool false
* @access public
*/
var $useTable = false;
/**
* schema method
*
*
* @access public
* @return void
*/
@ -102,21 +102,21 @@ class HelperTestComment extends Model {
}
/**
* HelperTestTag class
*
*
* @package cake
* @subpackage cake.tests.cases.libs.view
*/
class HelperTestTag extends Model {
/**
* useTable property
*
*
* @var bool false
* @access public
*/
var $useTable = false;
/**
* schema method
*
*
* @access public
* @return void
*/
@ -132,21 +132,21 @@ class HelperTestTag extends Model {
}
/**
* HelperTestPostsTag class
*
*
* @package cake
* @subpackage cake.tests.cases.libs.view
*/
class HelperTestPostsTag extends Model {
/**
* useTable property
*
*
* @var bool false
* @access public
*/
var $useTable = false;
/**
* schema method
*
*
* @access public
* @return void
*/
@ -168,7 +168,7 @@ class HelperTestPostsTag extends Model {
class HelperTest extends CakeTestCase {
/**
* setUp method
*
*
* @access public
* @return void
*/
@ -184,7 +184,7 @@ class HelperTest extends CakeTestCase {
}
/**
* testFormFieldNameParsing method
*
*
* @access public
* @return void
*/
@ -320,7 +320,7 @@ class HelperTest extends CakeTestCase {
}
/**
* testFieldsWithSameName method
*
*
* @access public
* @return void
*/
@ -355,7 +355,7 @@ class HelperTest extends CakeTestCase {
}
/**
* testFieldSameAsModel method
*
*
* @access public
* @return void
*/
@ -376,7 +376,7 @@ class HelperTest extends CakeTestCase {
}
/**
* testFieldSuffixForDate method
*
*
* @access public
* @return void
*/
@ -401,7 +401,7 @@ class HelperTest extends CakeTestCase {
}
/**
* testMulitDimensionValue method
*
*
* @access public
* @return void
*/
@ -434,7 +434,7 @@ class HelperTest extends CakeTestCase {
}
/**
* testClean method
*
*
* @access public
* @return void
*/
@ -447,16 +447,22 @@ class HelperTest extends CakeTestCase {
$result = $this->Helper->clean('<script>with something</script>');
$this->assertEqual($result, 'with something');
$result = $this->Helper->clean('<script type="text/javascript">alert("ruined");</script>');
$this->assertNoPattern('#</*script#', $result);
$result = $this->Helper->clean("<script \ntype=\"text/javascript\">\n\talert('ruined');\n\n\t\t</script>");
$this->assertNoPattern('#</*script#', $result);
$result = $this->Helper->clean('<body/onload=do(/something/)>');
$this->assertEqual($result, '<body/>');
$result = $this->Helper->clean('&lt;script&gt;alert(document.cookie)&lt;/script&gt;');
$this->assertEqual($result, '&amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;');
}
/**
* tearDown method
*
*
* @access public
* @return void
*/
@ -465,5 +471,4 @@ class HelperTest extends CakeTestCase {
ClassRegistry::flush();
}
}
?>

View file

@ -613,7 +613,7 @@ class ViewTest extends CakeTestCase {
@unlink($path);
}
/**
* testRenderNocache method
* testRenderNocache method
*
* @access public
* @return void