22        $definition = 
$config->getHTMLDefinition();
 
   26        $escape_invalid_tags = 
$config->get(
'Core.EscapeInvalidTags');
 
   27        $remove_invalid_img = 
$config->get(
'Core.RemoveInvalidImg');
 
   30        $trusted = 
$config->get(
'HTML.Trusted');
 
   31        $comment_lookup = 
$config->get(
'HTML.AllowedComments');
 
   32        $comment_regexp = 
$config->get(
'HTML.AllowedCommentsRegexp');
 
   33        $check_comments = $comment_lookup !== array() || $comment_regexp !== 
null;
 
   35        $remove_script_contents = 
$config->get(
'Core.RemoveScriptContents');
 
   36        $hidden_elements = 
$config->get(
'Core.HiddenElements');
 
   39        if ($remove_script_contents === 
true) {
 
   40            $hidden_elements[
'script'] = 
true;
 
   41        } elseif ($remove_script_contents === 
false && isset($hidden_elements[
'script'])) {
 
   42            unset($hidden_elements[
'script']);
 
   48        $remove_until = 
false;
 
   51        $textify_comments = 
false;
 
   57        if (
$config->get(
'Core.CollectErrors')) {
 
   58            $e =& 
$context->get(
'ErrorCollector');
 
   61        foreach ($tokens as 
$token) {
 
   63                if (empty(
$token->is_tag) || 
$token->name !== $remove_until) {
 
   67            if (!empty(
$token->is_tag)) {
 
   71                if (isset($definition->info_tag_transform[
$token->name])) {
 
   72                    $original_name = 
$token->name;
 
   78                        $e->send(E_NOTICE, 
'Strategy_RemoveForeignElements: Tag transform', $original_name);
 
   82                if (isset($definition->info[
$token->name])) {
 
   86                        $definition->info[
$token->name]->required_attr &&
 
   87                        (
$token->name != 
'img' || $remove_invalid_img) 
 
   91                        foreach ($definition->info[
$token->name]->required_attr as 
$name) {
 
  101                                    'Strategy_RemoveForeignElements: Missing required attribute',
 
  107                        $token->armor[
'ValidateAttributes'] = 
true;
 
  111                        $textify_comments = 
$token->name;
 
  113                        $textify_comments = 
false;
 
  116                } elseif ($escape_invalid_tags) {
 
  119                        $e->send(E_WARNING, 
'Strategy_RemoveForeignElements: Foreign element to text');
 
  122                        $generator->generateFromToken(
$token)
 
  127                    if (isset($hidden_elements[
$token->name])) {
 
  129                            $remove_until = 
$token->name;
 
  133                            $remove_until = 
false;
 
  136                            $e->send(E_ERROR, 
'Strategy_RemoveForeignElements: Foreign meta element removed');
 
  140                            $e->send(E_ERROR, 
'Strategy_RemoveForeignElements: Foreign element removed');
 
  147                if ($textify_comments !== 
false) {
 
  150                } elseif ($trusted || $check_comments) {
 
  152                    $trailing_hyphen = 
false;
 
  155                        if (substr(
$token->data, -1) == 
'-') {
 
  156                            $trailing_hyphen = 
true;
 
  160                    $found_double_hyphen = 
false;
 
  161                    while (strpos(
$token->data, 
'--') !== 
false) {
 
  162                        $found_double_hyphen = 
true;
 
  165                    if ($trusted || !empty($comment_lookup[trim(
$token->data)]) ||
 
  166                        ($comment_regexp !== 
null && preg_match($comment_regexp, trim(
$token->data)))) {
 
  169                            if ($trailing_hyphen) {
 
  172                                    'Strategy_RemoveForeignElements: Trailing hyphen in comment removed' 
  175                            if ($found_double_hyphen) {
 
  176                                $e->send(E_NOTICE, 
'Strategy_RemoveForeignElements: Hyphens in comment collapsed');
 
  181                            $e->send(E_NOTICE, 
'Strategy_RemoveForeignElements: Comment removed');
 
  188                        $e->send(E_NOTICE, 
'Strategy_RemoveForeignElements: Comment removed');
 
  198        if ($remove_until && $e) {
 
  200            $e->send(E_ERROR, 
'Strategy_RemoveForeignElements: Token removed to end', $remove_until);
 
An exception for terminatinating execution or to throw for unit testing.
Validates the attributes of a token.
Generates HTML from tokens.
Removes all unrecognized tags from the list of tokens.
execute($tokens, $config, $context)
Supertype for classes that define a strategy for modifying/purifying tokens.
Concrete empty token class.
Concrete end token class.
Concrete start token class.
Concrete text token class.