1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-03 20:58:11 +02:00

Add ParseType validator.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1600 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-04 14:33:38 +00:00
parent c0b5bc3eea
commit b9eb44bf03
4 changed files with 67 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
<?php
/**
* Parses TYPE into _TYPE and _NULL. Expects TYPE and ID to exist.
*/
class HTMLPurifier_ConfigSchema_Validator_ParseType extends HTMLPurifier_ConfigSchema_Validator
{
public function validate(&$arr, $interchange) {
$r = explode('/', $arr['TYPE'], 2);
if (!isset($interchange->types[$r[0]])) {
$this->error('Invalid type ' . $r[0] . ' for configuration directive ' . $arr['ID']);
}
$arr['_TYPE'] = $r[0];
$arr['_NULL'] = (isset($r[1]) && $r[1] === 'null');
}
}