|
Revision 7791, 1.7 kB
(checked in by fabien, 5 years ago)
|
updated Sean Kerr email address
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id Rev Date
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
class sfHtmlValidator extends sfValidator |
|---|
| 21 |
{ |
|---|
| 22 |
|
|---|
| 23 |
* Executes this validator. |
|---|
| 24 |
* |
|---|
| 25 |
* @param mixed A file or parameter value/array |
|---|
| 26 |
* @param error An error message reference |
|---|
| 27 |
* |
|---|
| 28 |
* @return bool true, if this validator executes successfully, otherwise false |
|---|
| 29 |
*/ |
|---|
| 30 |
public function execute(&$value, &$error) |
|---|
| 31 |
{ |
|---|
| 32 |
if (trim(strip_tags($value)) == '') |
|---|
| 33 |
{ |
|---|
| 34 |
|
|---|
| 35 |
if (preg_match('/<img/i', $value) || preg_match('/<object/i', $value)) |
|---|
| 36 |
return true; |
|---|
| 37 |
else |
|---|
| 38 |
{ |
|---|
| 39 |
$error = $this->getParameterHolder()->get('html_error'); |
|---|
| 40 |
return false; |
|---|
| 41 |
} |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
return true; |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
* Initializes this validator. |
|---|
| 49 |
* |
|---|
| 50 |
* @param sfContext The current application context |
|---|
| 51 |
* @param array An associative array of initialization parameters |
|---|
| 52 |
* |
|---|
| 53 |
* @return bool true, if initialization completes successfully, otherwise false |
|---|
| 54 |
*/ |
|---|
| 55 |
public function initialize($context, $parameters = null) |
|---|
| 56 |
{ |
|---|
| 57 |
|
|---|
| 58 |
parent::initialize($context); |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
$this->getParameterHolder()->set('html_error', 'Invalid input'); |
|---|
| 62 |
|
|---|
| 63 |
$this->getParameterHolder()->add($parameters); |
|---|
| 64 |
|
|---|
| 65 |
return true; |
|---|
| 66 |
} |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|