2016-06-30 21:42:40 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_HTMLModule_TargetNoreferrerTest extends HTMLPurifier_HTMLModuleHarness
|
|
|
|
{
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->config->set('HTML.TargetNoreferrer', true);
|
2017-01-13 17:21:24 +01:00
|
|
|
$this->config->set('HTML.TargetNoopener', false);
|
2016-06-30 21:42:40 -04:00
|
|
|
$this->config->set('Attr.AllowedFrameTargets', '_blank');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNoreferrer()
|
|
|
|
{
|
|
|
|
$this->assertResult(
|
|
|
|
'<a href="http://google.com" target="_blank">x</a>',
|
|
|
|
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNoreferrerNoDupe()
|
|
|
|
{
|
|
|
|
$this->config->set('Attr.AllowedRel', 'noreferrer');
|
|
|
|
$this->assertResult(
|
|
|
|
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>',
|
|
|
|
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTargetBlankNoreferrer()
|
|
|
|
{
|
|
|
|
$this->config->set('HTML.TargetBlank', true);
|
|
|
|
$this->assertResult(
|
|
|
|
'<a href="http://google.com">x</a>',
|
|
|
|
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-01-13 17:21:24 +01:00
|
|
|
public function testNoTarget()
|
|
|
|
{
|
|
|
|
$this->assertResult(
|
|
|
|
'<a href="http://google.com">x</a>',
|
|
|
|
'<a href="http://google.com">x</a>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-30 21:42:40 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// vim: et sw=4 sts=4
|