Fixes #5025, UTF8 signs are not treated correctly at form validation

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7320 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-07-05 13:25:22 +00:00
parent 1c2b1ef8eb
commit d853520e46
2 changed files with 81 additions and 79 deletions

View file

@ -39,7 +39,7 @@
define('VALID_NUMBER', '/^[-+]?\\b[0-9]*\\.?[0-9]+\\b$/'); define('VALID_NUMBER', '/^[-+]?\\b[0-9]*\\.?[0-9]+\\b$/');
/** /**
* A valid email address. * A valid email address.
*/ */
define('VALID_EMAIL', "/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-z]{2,4}|museum|travel)$/i"); define('VALID_EMAIL', "/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-z]{2,4}|museum|travel)$/i");
/** /**
* A valid year (1000-2999). * A valid year (1000-2999).
@ -139,13 +139,8 @@ class Validation extends Object {
if (empty($_this->check) && $_this->check != '0') { if (empty($_this->check) && $_this->check != '0') {
return false; return false;
} }
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu';
$_this->regex = '/[^\\dA-Z]/i'; return $_this->_check();
if ($_this->_check() === true) {
return false;
} else {
return true;
}
} }
/** /**
* Checks that a string length is within s specified range. * Checks that a string length is within s specified range.
@ -556,7 +551,7 @@ class Validation extends Object {
// } // }
// return true; // return true;
// } // }
// //
// return preg_match('/[\w| |_]+\.[\w]+/', $check); // return preg_match('/[\w| |_]+\.[\w]+/', $check);
} }
/** /**
@ -911,4 +906,4 @@ class Validation extends Object {
$_this->type = null; $_this->type = null;
} }
} }
?> ?>

View file

@ -29,7 +29,7 @@
App::import('Core', 'Validation'); App::import('Core', 'Validation');
/** /**
* CustomValidator class * CustomValidator class
* *
* @package cake * @package cake
* @subpackage cake.tests.cases.libs * @subpackage cake.tests.cases.libs
*/ */
@ -55,14 +55,14 @@ class CustomValidator {
class ValidationTestCase extends UnitTestCase { class ValidationTestCase extends UnitTestCase {
/** /**
* Validation property * Validation property
* *
* @var mixed null * @var mixed null
* @access public * @access public
*/ */
var $Validation = null; var $Validation = null;
/** /**
* setup method * setup method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -71,7 +71,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testAlphaNumeric method * testAlphaNumeric method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -80,6 +80,13 @@ class ValidationTestCase extends UnitTestCase {
$this->assertTrue(Validation::alphaNumeric('12234')); $this->assertTrue(Validation::alphaNumeric('12234'));
$this->assertTrue(Validation::alphaNumeric('1w2e2r3t4y')); $this->assertTrue(Validation::alphaNumeric('1w2e2r3t4y'));
$this->assertTrue(Validation::alphaNumeric('0')); $this->assertTrue(Validation::alphaNumeric('0'));
$this->assertTrue(Validation::alphaNumeric('abçďĕʑʘπй'));
$this->assertTrue(Validation::alphaNumeric('ˇˆๆゞ'));
$this->assertTrue(Validation::alphaNumeric('אกあアꀀ豈'));
$this->assertTrue(Validation::alphaNumeric('Džᾈᾨ'));
$this->assertTrue(Validation::alphaNumeric('ÆΔΩЖÇ'));
$this->assertFalse(Validation::alphaNumeric('12 234')); $this->assertFalse(Validation::alphaNumeric('12 234'));
$this->assertFalse(Validation::alphaNumeric('dfd 234')); $this->assertFalse(Validation::alphaNumeric('dfd 234'));
$this->assertFalse(Validation::alphaNumeric("\n")); $this->assertFalse(Validation::alphaNumeric("\n"));
@ -90,7 +97,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testAlphaNumericPassedAsArray method * testAlphaNumericPassedAsArray method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -109,7 +116,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testBetween method * testBetween method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -120,7 +127,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testBlank method * testBlank method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -135,7 +142,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testBlankAsArray method * testBlankAsArray method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -150,7 +157,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testcc method * testcc method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -594,7 +601,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testLuhn method * testLuhn method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -673,7 +680,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testCustomRegexForCc method * testCustomRegexForCc method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -684,7 +691,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testCustomRegexForCcWithLuhnCheck method * testCustomRegexForCcWithLuhnCheck method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -696,7 +703,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testFastCc method * testFastCc method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -722,7 +729,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testAllCc method * testAllCc method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -772,7 +779,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testAllCcDeep method * testAllCcDeep method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -822,7 +829,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testComparison method * testComparison method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -858,7 +865,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testComparisonAsArray method * testComparisonAsArray method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -894,7 +901,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testCustom method * testCustom method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -905,7 +912,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testCustomAsArray method * testCustomAsArray method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -916,7 +923,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDdmmyyyy method * testDateDdmmyyyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -936,7 +943,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDdmmyyyyLeapYear method * testDateDdmmyyyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -952,7 +959,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDdmmyy method * testDateDdmmyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -972,7 +979,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDdmmyyLeapYear method * testDateDdmmyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -988,7 +995,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDmyy method * testDateDmyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1008,7 +1015,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDmyyLeapYear method * testDateDmyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1024,7 +1031,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDmyyyy method * testDateDmyyyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1044,7 +1051,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDmyyyyLeapYear method * testDateDmyyyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1060,7 +1067,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMmddyyyy method * testDateMmddyyyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1080,7 +1087,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMmddyyyyLeapYear method * testDateMmddyyyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1096,7 +1103,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMmddyy method * testDateMmddyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1116,7 +1123,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMmddyyLeapYear method * testDateMmddyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1132,7 +1139,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMdyy method * testDateMdyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1152,7 +1159,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMdyyLeapYear method * testDateMdyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1168,7 +1175,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMdyyyy method * testDateMdyyyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1188,7 +1195,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMdyyyyLeapYear method * testDateMdyyyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1204,7 +1211,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateYyyymmdd method * testDateYyyymmdd method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1220,7 +1227,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateYyyymmddLeapYear method * testDateYyyymmddLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1236,7 +1243,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateYymmdd method * testDateYymmdd method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1256,7 +1263,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateYymmddLeapYear method * testDateYymmddLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1272,7 +1279,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDdMMMMyyyy method * testDateDdMMMMyyyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1284,7 +1291,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateDdMMMMyyyyLeapYear method * testDateDdMMMMyyyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1294,7 +1301,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMmmmDdyyyy method * testDateMmmmDdyyyy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1308,7 +1315,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMmmmDdyyyyLeapYear method * testDateMmmmDdyyyyLeapYear method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1321,7 +1328,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMy method * testDateMy method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1333,7 +1340,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateMyNumeric method * testDateMyNumeric method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1349,7 +1356,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testTime method * testTime method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1370,7 +1377,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testBoolean method * testBoolean method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1389,7 +1396,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDateCustomRegx method * testDateCustomRegx method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1399,7 +1406,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDecimal method * testDecimal method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1417,7 +1424,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDecimalWithPlaces method * testDecimalWithPlaces method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1441,7 +1448,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testDecimalCustomRegex method * testDecimalCustomRegex method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1451,7 +1458,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testEmail method * testEmail method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1523,7 +1530,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testEmailDeep method * testEmailDeep method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1534,7 +1541,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testEmailCustomRegex method * testEmailCustomRegex method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1544,7 +1551,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testEqualTo method * testEqualTo method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1558,7 +1565,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testIp method * testIp method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1572,7 +1579,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testMaxLength method * testMaxLength method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1583,7 +1590,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testMinLength method * testMinLength method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1594,7 +1601,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testUrl method * testUrl method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1628,7 +1635,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testInList method * testInList method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1639,7 +1646,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testValidNumber method * testValidNumber method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1665,7 +1672,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testRange method * testRange method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1680,7 +1687,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testExtension method * testExtension method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1709,7 +1716,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testMoney method * testMoney method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1741,7 +1748,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testNumeric method * testNumeric method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1757,7 +1764,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testPhone method * testPhone method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1779,7 +1786,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testPostal method * testPostal method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1831,7 +1838,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testSsn method * testSsn method
* *
* @access public * @access public
* @return void * @return void
*/ */
@ -1852,7 +1859,7 @@ class ValidationTestCase extends UnitTestCase {
} }
/** /**
* testUserDefined method * testUserDefined method
* *
* @access public * @access public
* @return void * @return void
*/ */