Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Not an Issue
-
Affects Version/s: 1.9.6, 1.10.2
-
Fix Version/s: 1.10.3
-
Component/s: Zend_Filter_Input
-
Labels:None
Description
This is a test code:
<?php
require_once('Zend/Filter/Input.php');
$options = array(
'escapeFilter' => array('StringTrim'),
'breakChainOnFailure' => true,
'presence' => 'required'
);
$filters = array('account' => 'StringToUpper');
$validators = array('account' => 'Alpha');
$data['account'] = 'sdfgsdgGRDW';
$input = new Zend_Filter_Input($filters, $validators, $data, $options);
if ($input->isValid()) {
var_dump('Hooray');
for($i = 0; $i < 5; $i++){
var_dump($input->account);
}
} else {
var_dump('Not valid');
}
?>
1. Just did run the Zend_Filter_Input througt the Xdebug and found that accessing the value($input->account) generate a getEscaped() functionality by default which was done when you access the isValid(). My opinion it should use the "getUnescaped()" by default if you used the isValid().
2. if a value of $data['account'] is ' sdfgsdgGRDW', has the white spaces, it returns the 'Not valid' result. It does not care that my 'escapeFilter' is the 'StringTrim'. Should it go through the Filters first and then Validations?
Cheers
to 1.)
When calling __get (also explicit) getEscaped() is correct.
For security reasons Zend_Filter_Input will always return a value which conforms the security.
to 2.)
According to the manual the espaceFilters are processed AFTER validation (different than the other filters). Returning a FALSE is correct within the given examples.