2008-03-04 15:06:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses string representations into their corresponding native PHP
|
|
|
|
* variable type.
|
|
|
|
*/
|
2008-03-05 03:51:09 +00:00
|
|
|
abstract class HTMLPurifier_VarParser
|
2008-03-04 15:06:00 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup table of allowed types.
|
|
|
|
*/
|
2008-03-05 03:51:09 +00:00
|
|
|
static public $types = array(
|
2008-03-04 15:06:00 +00:00
|
|
|
'string' => true,
|
|
|
|
'istring' => true,
|
|
|
|
'text' => true,
|
|
|
|
'itext' => true,
|
|
|
|
'int' => true,
|
|
|
|
'float' => true,
|
|
|
|
'bool' => true,
|
|
|
|
'lookup' => true,
|
|
|
|
'list' => true,
|
|
|
|
'hash' => true,
|
|
|
|
'mixed' => true
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2008-03-05 03:51:09 +00:00
|
|
|
* Validate a variable according to type. Throws
|
|
|
|
* HTMLPurifier_VarParserException if invalid.
|
|
|
|
* It may return NULL as a valid type if $allow_null is true.
|
|
|
|
*
|
|
|
|
* @param $var Variable to validate
|
|
|
|
* @param $type Type of variable, see HTMLPurifier_VarParser->types
|
|
|
|
* @param $allow_null Whether or not to permit null as a value
|
|
|
|
* @return Validated and type-coerced variable
|
2008-03-04 15:06:00 +00:00
|
|
|
*/
|
2008-03-05 03:51:09 +00:00
|
|
|
abstract public function parse($var, $type, $allow_null = false);
|
2008-03-04 15:06:00 +00:00
|
|
|
|
|
|
|
}
|