filter() public méthode

Apply filters to the attributes list.
public filter ( string $tag, array $attributes ) : array
$tag string Tag name
$attributes array Attributes dictionary
Résultat array Filtered attributes
Exemple #1
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;
 }
 public function testFilterProtocolAttribute()
 {
     $filter = new Attribute(new Url('http://google.com'));
     $this->assertTrue($filter->filterProtocolUrlAttribute('a', 'href', 'http://google.fr/'));
     $this->assertFalse($filter->filterProtocolUrlAttribute('a', 'href', 'bla://google.fr/'));
     $this->assertFalse($filter->filterProtocolUrlAttribute('a', 'href', 'javascript:alert("test")'));
     $this->assertEquals(array('href' => 'http://google.fr/'), $filter->filter('a', array('href' => 'http://google.fr/')));
     $this->assertEquals(array(), $filter->filter('a', array('href' => 'bla://google.fr/')));
 }