isAllowed() public method

Check if the tag is allowed and is not a pixel tracker.
public isAllowed ( string $tag, array $attributes ) : boolean
$tag string Tag name
$attributes array Attributes dictionary
return boolean
 public function testAllowedTag()
 {
     $tag = new Tag();
     $this->assertTrue($tag->isAllowed('p', array('class' => 'test')));
     $this->assertTrue($tag->isAllowed('img', array('class' => 'test')));
     $this->assertFalse($tag->isAllowed('script', array('class' => 'test')));
     $this->assertFalse($tag->isAllowed('img', array('width' => '1', 'height' => '1')));
 }
Example #2
0
 /**
  * Parse opening tag.
  *
  * @param resource $parser     XML parser
  * @param string   $tag        Tag name
  * @param array    $attributes Tag attributes
  */
 public function startTag($parser, $tag, array $attributes)
 {
     $this->empty = true;
     if ($this->tag->isAllowed($tag, $attributes)) {
         $attributes = $this->attribute->filter($tag, $attributes);
         if ($this->attribute->hasRequiredAttributes($tag, $attributes)) {
             $attributes = $this->attribute->addAttributes($tag, $attributes);
             $this->output .= $this->tag->openHtmlTag($tag, $this->attribute->toHtml($attributes));
             $this->empty = false;
         }
     }
     $this->empty_tags[] = $this->empty;
 }