mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-05-20 14:33:27 +00:00
Merge branch '27-pages-fix' into 2.7
This commit is contained in:
commit
1a6f733286
4 changed files with 29 additions and 104 deletions
lib/Cake
|
@ -183,25 +183,6 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::alphaNumeric(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* testAlphaNumericPassedAsArray method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAlphaNumericPassedAsArray() {
|
||||
$this->assertTrue(Validation::alphaNumeric(array('check' => 'frferrf')));
|
||||
$this->assertTrue(Validation::alphaNumeric(array('check' => '12234')));
|
||||
$this->assertTrue(Validation::alphaNumeric(array('check' => '1w2e2r3t4y')));
|
||||
$this->assertTrue(Validation::alphaNumeric(array('check' => '0')));
|
||||
$this->assertFalse(Validation::alphaNumeric(array('check' => '12 234')));
|
||||
$this->assertFalse(Validation::alphaNumeric(array('check' => 'dfd 234')));
|
||||
$this->assertFalse(Validation::alphaNumeric(array('check' => "\n")));
|
||||
$this->assertFalse(Validation::alphaNumeric(array('check' => "\t")));
|
||||
$this->assertFalse(Validation::alphaNumeric(array('check' => "\r")));
|
||||
$this->assertFalse(Validation::alphaNumeric(array('check' => ' ')));
|
||||
$this->assertFalse(Validation::alphaNumeric(array('check' => '')));
|
||||
}
|
||||
|
||||
/**
|
||||
* testLengthBetween method
|
||||
*
|
||||
|
@ -231,21 +212,6 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::blank('Blank'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testBlankAsArray method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBlankAsArray() {
|
||||
$this->assertTrue(Validation::blank(array('check' => '')));
|
||||
$this->assertTrue(Validation::blank(array('check' => ' ')));
|
||||
$this->assertTrue(Validation::blank(array('check' => "\n")));
|
||||
$this->assertTrue(Validation::blank(array('check' => "\t")));
|
||||
$this->assertTrue(Validation::blank(array('check' => "\r")));
|
||||
$this->assertFalse(Validation::blank(array('check' => ' Blank')));
|
||||
$this->assertFalse(Validation::blank(array('check' => 'Blank')));
|
||||
}
|
||||
|
||||
/**
|
||||
* testcc method
|
||||
*
|
||||
|
@ -999,17 +965,6 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::custom('missing regex'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testCustomAsArray method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomAsArray() {
|
||||
$this->assertTrue(Validation::custom(array('check' => '12345', 'regex' => '/(?<!\\S)\\d++(?!\\S)/')));
|
||||
$this->assertFalse(Validation::custom(array('check' => 'Text', 'regex' => '/(?<!\\S)\\d++(?!\\S)/')));
|
||||
$this->assertFalse(Validation::custom(array('check' => '123.45', 'regex' => '/(?<!\\S)\\d++(?!\\S)/')));
|
||||
}
|
||||
|
||||
/**
|
||||
* testDateDdmmyyyy method
|
||||
*
|
||||
|
|
|
@ -395,6 +395,26 @@ class ViewTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that plugin files with absolute file paths are scoped
|
||||
* to the plugin and do now allow any file path.
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @return void
|
||||
*/
|
||||
public function testPluginGetTemplateAbsoluteFail() {
|
||||
$this->Controller->viewPath = 'Pages';
|
||||
$this->Controller->action = 'display';
|
||||
$this->Controller->params['pass'] = array('home');
|
||||
|
||||
$view = new TestThemeView($this->Controller);
|
||||
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'Company' . DS . 'TestPluginThree' . DS . 'View' . DS . 'Pages' . DS . 'index.ctp';
|
||||
$result = $view->getViewFileName('Company/TestPluginThree./Pages/index');
|
||||
$this->assertPathEquals($expected, $result);
|
||||
|
||||
$view->getViewFileName('Company/TestPluginThree./etc/passwd');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getLayoutFileName method on plugin
|
||||
*
|
||||
|
|
|
@ -73,10 +73,9 @@ class Validation {
|
|||
* @return bool Success
|
||||
*/
|
||||
public static function notBlank($check) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
if (!is_scalar($check)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($check) && (string)$check !== '0') {
|
||||
return false;
|
||||
}
|
||||
|
@ -95,10 +94,6 @@ class Validation {
|
|||
* @return bool Success
|
||||
*/
|
||||
public static function alphaNumeric($check) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
}
|
||||
|
||||
if (empty($check) && $check != '0') {
|
||||
return false;
|
||||
}
|
||||
|
@ -145,9 +140,6 @@ class Validation {
|
|||
* @return bool Success
|
||||
*/
|
||||
public static function blank($check) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
}
|
||||
return !static::_check($check, '/[^\\s]/');
|
||||
}
|
||||
|
||||
|
@ -166,8 +158,8 @@ class Validation {
|
|||
* @see Validation::luhn()
|
||||
*/
|
||||
public static function cc($check, $type = 'fast', $deep = false, $regex = null) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
if (!is_scalar($check)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$check = str_replace(array('-', ' '), '', $check);
|
||||
|
@ -300,8 +292,8 @@ class Validation {
|
|||
* @return bool Success
|
||||
*/
|
||||
public static function custom($check, $regex = null) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
if (!is_scalar($check)) {
|
||||
return false;
|
||||
}
|
||||
if ($regex === null) {
|
||||
static::$errors[] = __d('cake_dev', 'You must define a regular expression for %s', 'Validation::custom()');
|
||||
|
@ -480,10 +472,6 @@ class Validation {
|
|||
* @return bool Success
|
||||
*/
|
||||
public static function email($check, $deep = false, $regex = null) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
}
|
||||
|
||||
if ($regex === null) {
|
||||
$regex = '/^[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . static::$_pattern['hostname'] . '$/ui';
|
||||
}
|
||||
|
@ -670,10 +658,6 @@ class Validation {
|
|||
* @return bool Success
|
||||
*/
|
||||
public static function phone($check, $regex = null, $country = 'all') {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
}
|
||||
|
||||
if ($regex === null) {
|
||||
switch ($country) {
|
||||
case 'us':
|
||||
|
@ -715,10 +699,6 @@ class Validation {
|
|||
* @return bool Success
|
||||
*/
|
||||
public static function postal($check, $regex = null, $country = 'us') {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
}
|
||||
|
||||
if ($regex === null) {
|
||||
switch ($country) {
|
||||
case 'uk':
|
||||
|
@ -780,10 +760,6 @@ class Validation {
|
|||
* @deprecated Deprecated 2.6. Will be removed in 3.0.
|
||||
*/
|
||||
public static function ssn($check, $regex = null, $country = null) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
}
|
||||
|
||||
if ($regex === null) {
|
||||
switch ($country) {
|
||||
case 'dk':
|
||||
|
@ -905,35 +881,12 @@ class Validation {
|
|||
* @return bool Success of match
|
||||
*/
|
||||
protected static function _check($check, $regex) {
|
||||
if (is_string($regex) && preg_match($regex, $check)) {
|
||||
if (is_string($regex) && is_scalar($check) && preg_match($regex, $check)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the values to use when value sent to validation method is
|
||||
* an array.
|
||||
*
|
||||
* @param array $params Parameters sent to validation method
|
||||
* @return void
|
||||
*/
|
||||
protected static function _defaults($params) {
|
||||
static::_reset();
|
||||
$defaults = array(
|
||||
'check' => null,
|
||||
'regex' => null,
|
||||
'country' => null,
|
||||
'deep' => false,
|
||||
'type' => null
|
||||
);
|
||||
$params += $defaults;
|
||||
if ($params['country'] !== null) {
|
||||
$params['country'] = mb_strtolower($params['country']);
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Luhn algorithm
|
||||
*
|
||||
|
@ -943,8 +896,8 @@ class Validation {
|
|||
* @see http://en.wikipedia.org/wiki/Luhn_algorithm
|
||||
*/
|
||||
public static function luhn($check, $deep = false) {
|
||||
if (is_array($check)) {
|
||||
extract(static::_defaults($check));
|
||||
if (!is_scalar($check)) {
|
||||
return false;
|
||||
}
|
||||
if ($deep !== true) {
|
||||
return true;
|
||||
|
|
|
@ -1012,9 +1012,6 @@ class View extends Object {
|
|||
$name = $this->viewPath . DS . $subDir . Inflector::underscore($name);
|
||||
} elseif (strpos($name, DS) !== false) {
|
||||
if ($name[0] === DS || $name[1] === ':') {
|
||||
if (is_file($name)) {
|
||||
return $name;
|
||||
}
|
||||
$name = trim($name, DS);
|
||||
} elseif ($name[0] === '.') {
|
||||
$name = substr($name, 3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue