PicoFeed\Filter\Attribute::filterProtocolUrlAttribute PHP Méthode

filterProtocolUrlAttribute() public méthode

Return true if the scheme is authorized.
public filterProtocolUrlAttribute ( string $tag, string $attribute, string $value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
Résultat boolean
    public function filterProtocolUrlAttribute($tag, $attribute, $value)
    {
        if ($this->isResource($attribute) && !$this->isAllowedProtocol($value)) {
            return false;
        }
        return true;
    }

Usage Example

 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/')));
 }