diff --git a/NEWS b/NEWS index e93192d8..8c07d048 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier to true to use them. ! HTML Purifier now has its own Exception hierarchy under HTMLPurifier_Exception. Developer error (not enduser error) can cause these to be triggered. +! Experimental kses() wrapper introduced with HTMLPurifier.kses.php - Autoclose now operates iteratively, i.e.
now has both span tags closed. - Various HTMLPurifier_Config convenience functions now accept another parameter diff --git a/library/HTMLPurifier.kses.php b/library/HTMLPurifier.kses.php new file mode 100644 index 00000000..28314c4d --- /dev/null +++ b/library/HTMLPurifier.kses.php @@ -0,0 +1,28 @@ + $attributes) { + $allowed_elements[$element] = true; + foreach ($attributes as $attribute => $x) { + $allowed_attributes["$element.$attribute"] = true; + } + } + $config->set('HTML', 'AllowedElements', $allowed_elements); + $config->set('HTML', 'AllowedAttributes', $allowed_attributes); + $allowed_schemes = array(); + if ($allowed_protocols !== null) { + $config->set('URI', 'AllowedSchemes', $allowed_protocols); + } + $purifier = new HTMLPurifier($config); + return $purifier->purify($string); +} diff --git a/tests/HTMLPurifier/PHPT/kses/basic.phpt b/tests/HTMLPurifier/PHPT/kses/basic.phpt new file mode 100644 index 00000000..da2c05a8 --- /dev/null +++ b/tests/HTMLPurifier/PHPT/kses/basic.phpt @@ -0,0 +1,15 @@ +--TEST-- +HTMLPurifier.kses.php basic test +--FILE-- +FooBar', + array( + 'a' => array('class' => 1, 'href' => 1), + ), + array('http') // no https! +); + +--EXPECT-- +FooBar