Skip to content

Commit

Permalink
Fixing validation methods + features lost in [f51ce73] due to a bad
Browse files Browse the repository at this point in the history
merge.
Fixing additional tests to reflect changes in 2.0
  • Loading branch information
markstory committed Dec 11, 2010
1 parent b9f0fc0 commit 1e10874
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cake/libs/cake_session.php
Expand Up @@ -455,7 +455,7 @@ public static function write($name, $value = null) {
}
foreach ($write as $key => $val) {
if (in_array($key, self::$watchKeys)) {
trigger_error(__('Writing session key {%s}: %s', $key, Debugger::exportVar($val)), E_USER_NOTICE);
trigger_error(__('Writing session key {%s}: %s', $key, var_export($val, true)), E_USER_NOTICE);
}
self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
if (Set::classicExtract($_SESSION, $key) !== $val) {
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/controller/scaffold.php
Expand Up @@ -260,7 +260,7 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
if ($this->ScaffoldModel->save($request->data)) {
if ($this->controller->_afterScaffoldSave($action)) {
$message = sprintf(
__('The %1$s has been %2$s', true),
__('The %1$s has been %2$s'),
Inflector::humanize($this->modelKey),
$success
);
Expand Down Expand Up @@ -328,7 +328,7 @@ protected function _scaffoldDelete(CakeRequest $request) {
$message = sprintf(
__('There was an error deleting the %1$s with id: %2$d', true),
Inflector::humanize($this->modelClass), $id
));
);
return $this->_sendMessage($message);
}
} elseif ($this->controller->_scaffoldError('delete') === false) {
Expand Down
16 changes: 14 additions & 2 deletions cake/libs/validation.php
Expand Up @@ -670,10 +670,10 @@ public static function url($check, $strict = false) {
self::__populateIp();
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
$regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
'(?:' . self::$__pattern['IPv4'] . '|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' .
'(?:' . self::$__pattern['IPv4'] . '|\[' . self::$__pattern['IPv6'] . '\]|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
'(?:\/?|\/' . $validChars . '*)?' .
'(?:\?' . $validChars . '*)?' .
'(?:#' . $validChars . '*)?$/i';
'(?:#' . $validChars . '*)?$/iu';
return self::_check($check, $regex);
}

Expand Down Expand Up @@ -701,6 +701,18 @@ public static function userDefined($check, $object, $method, $args = null) {
return call_user_func_array(array($object, $method), array($check, $args));
}

/**
* Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122
*
* @param string $check Value to check
* @return boolean Success
* @access public
*/
public static function uuid($check) {
$regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
return self::_check($check, $regex);
}

/**
* Attempts to pass unhandled Validation locales to a class starting with $classPrefix
* and ending with Validation. For example $classPrefix = 'nl', the class would be
Expand Down
4 changes: 2 additions & 2 deletions cake/tests/cases/libs/controller/components/cookie.test.php
Expand Up @@ -465,10 +465,10 @@ function testReadingCookieDataWithoutStartup() {
* @return void
*/
function testNoErrorOnNonArrayData() {
$this->Controller->Cookie->destroy();
$this->Cookie->destroy();
$_COOKIE['CakeTestCookie'] = 'kaboom';

$this->assertNull($this->Controller->Cookie->read('value'));
$this->assertNull($this->Cookie->read('value'));
}

/**
Expand Down

0 comments on commit 1e10874

Please sign in to comment.