mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
fixed do not validate uploaded file name
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9014 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
455aeb4326
commit
8e20c6057e
1 changed files with 24 additions and 4 deletions
|
|
@ -26,7 +26,7 @@ class Validator
|
|||
$this->_xml_ruleset = null;
|
||||
|
||||
if($xml_path) $this->load($xml_path);
|
||||
|
||||
|
||||
// predefined rules
|
||||
$this->addRule(array(
|
||||
'email' => '/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/',
|
||||
|
|
@ -148,7 +148,7 @@ class Validator
|
|||
'if' => array()
|
||||
);
|
||||
|
||||
$fields = array_map('trim', $fields);
|
||||
$fields = array_map(array($this, 'arrayTrim'), $fields);
|
||||
$field_names = array_keys($fields);
|
||||
|
||||
$filters = $this->_filters;
|
||||
|
|
@ -237,6 +237,21 @@ class Validator
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* apply trim recursive
|
||||
*/
|
||||
function arrayTrim($array)
|
||||
{
|
||||
if (!is_array($array)) return trim($array);
|
||||
|
||||
foreach($array as $key => $value)
|
||||
{
|
||||
$array[$key] = $this->arrayTrim($value);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error
|
||||
* @param[in] $msg error message
|
||||
|
|
@ -305,7 +320,7 @@ class Validator
|
|||
unset($filter['if']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->_filters[$name] = $filter;
|
||||
}
|
||||
}
|
||||
|
|
@ -323,6 +338,11 @@ class Validator
|
|||
function applyRule($name, $value){
|
||||
$rule = $this->_rules[$name];
|
||||
|
||||
if (is_array($value) && isset($value['tmp_name']))
|
||||
{
|
||||
$value = $value['name'];
|
||||
}
|
||||
|
||||
switch($rule['type']) {
|
||||
case 'regex':
|
||||
return (preg_match($rule['test'], $value) > 0);
|
||||
|
|
@ -339,7 +359,7 @@ class Validator
|
|||
}
|
||||
|
||||
/**
|
||||
* Return
|
||||
* Return
|
||||
*/
|
||||
function mbStrLen($str){
|
||||
$arr = count_chars($str);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue