1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 21:57:26 +02:00

[1.4.0] YouTube preservation code added to the core by adding HTMLPurifier_Filter hierarchy.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@673 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-01-21 15:09:07 +00:00
parent 712d81ebea
commit 8d6bfa4037
7 changed files with 101 additions and 29 deletions

View File

@@ -67,6 +67,7 @@ class HTMLPurifier
var $version = '1.3.2';
var $config;
var $filters;
var $lexer, $strategy, $generator;
@@ -94,6 +95,14 @@ class HTMLPurifier
}
/**
* Adds a filter to process the output. First come first serve
* @param $filter HTMLPurifier_Filter object
*/
function addFilter($filter) {
$this->filters[] = $filter;
}
/**
* Filters an HTML snippet/document to be XSS-free and standards-compliant.
*
@@ -111,6 +120,10 @@ class HTMLPurifier
$context = new HTMLPurifier_Context();
$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
for ($i = 0, $size = count($this->filters); $i < $size; $i++) {
$html = $this->filters[$i]->preFilter($html, $config, $context);
}
// purified HTML
$html =
$this->generator->generateFromTokens(
@@ -126,6 +139,10 @@ class HTMLPurifier
$config, $context
);
for ($i = $size - 1; $i >= 0; $i--) {
$html = $this->filters[$i]->postFilter($html, $config, $context);
}
$html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
$this->context =& $context;
return $html;