1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-30 19:00:10 +02:00

Implement ParseDefault.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1608 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-05 05:49:18 +00:00
parent b65942a2c5
commit e83573a3ad
4 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<?php
/**
* Parses DEFAULT into _DEFAULT. Expects DEFAULT, _TYPE, _NULL and ID to exist.
*/
class HTMLPurifier_ConfigSchema_Validator_ParseDefault extends HTMLPurifier_ConfigSchema_Validator
{
public function validate(&$arr, $interchange) {
$parser = new HTMLPurifier_VarParser_Native(); // not configurable yet
try {
$arr['_DEFAULT'] = $parser->parse($arr['DEFAULT'], $arr['_TYPE'], $arr['_NULL']);
} catch (HTMLPurifier_VarParserException $e) {
throw new HTMLPurifier_ConfigSchema_Exception('Invalid type for default value in '. $arr['ID'] .': ' . $e->getMessage());
}
}
}