Changeset 11932
- Timestamp:
- 10/03/08 21:45:54 (5 years ago)
- Files:
-
- branches/1.1/lib/validator/sfValidatorError.class.php (modified) (1 diff)
- branches/1.1/test/unit/validator/sfValidatorDateTest.php (modified) (1 diff)
- branches/1.1/test/unit/validator/sfValidatorErrorTest.php (modified) (3 diffs)
- branches/1.1/test/unit/validator/sfValidatorTimeTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorError.class.php
r9048 r11932 92 92 foreach ($this->arguments as $key => $value) 93 93 { 94 $arguments["%$key%"] = $value; 94 if (is_array($value)) 95 { 96 continue; 97 } 98 99 $arguments["%$key%"] = htmlspecialchars($value, ENT_QUOTES, sfValidatorBase::getCharset()); 95 100 } 96 101 branches/1.1/test/unit/validator/sfValidatorDateTest.php
r9897 r11932 99 99 { 100 100 $t->pass('->clean() throws a sfValidatorError if the date does not match the regex'); 101 $t->like($e->getMessage(), '/'.preg_quote( $v->getOption('date_format'), '/').'/', '->clean() returns the expected date format in the error message');101 $t->like($e->getMessage(), '/'.preg_quote(htmlspecialchars($v->getOption('date_format'), ENT_QUOTES, 'UTF-8'), '/').'/', '->clean() returns the expected date format in the error message'); 102 102 $t->is($e->getCode(), 'bad_format', '->clean() throws a sfValidatorError'); 103 103 } branches/1.1/test/unit/validator/sfValidatorErrorTest.php
r5581 r11932 15 15 $v = new sfValidatorString(); 16 16 17 $e = new sfValidatorError($v, 'max_length', array('value' => 'foo ', 'max_length' => 1));17 $e = new sfValidatorError($v, 'max_length', array('value' => 'foo<br />', 'max_length' => 1)); 18 18 19 19 // ->getValue() 20 20 $t->diag('->getValue()'); 21 $t->is($e->getValue(), 'foo ', '->getValue() returns the value that has been validated with the validator');21 $t->is($e->getValue(), 'foo<br />', '->getValue() returns the value that has been validated with the validator'); 22 22 23 23 $e1 = new sfValidatorError($v, 'max_length', array('max_length' => 1)); … … 30 30 // ->getArguments() 31 31 $t->diag('->getArguments()'); 32 $t->is($e->getArguments(), array('%value%' => 'foo ', '%max_length%' => 1), '->getArguments() returns the arguments needed to format the error message');33 $t->is($e->getArguments(true), array('value' => 'foo ', 'max_length' => 1), '->getArguments() takes a Boolean as its first argument to return the raw arguments');32 $t->is($e->getArguments(), array('%value%' => 'foo<br />', '%max_length%' => 1), '->getArguments() returns the arguments needed to format the error message, escaped according to the current charset'); 33 $t->is($e->getArguments(true), array('value' => 'foo<br />', 'max_length' => 1), '->getArguments() takes a Boolean as its first argument to return the raw arguments'); 34 34 35 35 // ->getMessageFormat() … … 39 39 // ->getMessage() 40 40 $t->diag('->getMessage()'); 41 $t->is($e->getMessage(), '"foo " is too long (1 characters max).', '->getMessage() returns the error message string');41 $t->is($e->getMessage(), '"foo<br />" is too long (1 characters max).', '->getMessage() returns the error message string'); 42 42 43 43 // ->getCode() branches/1.1/test/unit/validator/sfValidatorTimeTest.php
r11549 r11932 100 100 { 101 101 $t->pass('->clean() throws a sfValidatorError if the time does not match the regex'); 102 $t->like($e->getMessage(), '/'.preg_quote( $v->getOption('time_format'), '/').'/', '->clean() returns the expected time format in the error message');102 $t->like($e->getMessage(), '/'.preg_quote(htmlspecialchars($v->getOption('time_format'), ENT_QUOTES, 'UTF-8'), '/').'/', '->clean() returns the expected time format in the error message'); 103 103 $t->is($e->getCode(), 'bad_format', '->clean() throws a sfValidatorError'); 104 104 }