2008-06-27 20:09:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setup()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
parent::setup();
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('AutoFormat.RemoveEmpty', true);
|
2008-06-27 20:09:14 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserve()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<b>asdf</b>');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemove()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<b></b>', '');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveWithSpace()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<b> </b>', '');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveWithAttr()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<b class="asdf"></b>', '');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveIdAndName()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<a id="asdf" name="asdf"></a>', '');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveColgroup()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<colgroup></colgroup>');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveId()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('Attr.EnableID', true);
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<a id="asdf"></a>');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveName()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('Attr.EnableID', true);
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<a name="asdf"></a>');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveNested()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<b><i></i></b>', '');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveNested2()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<b><i><u></u></i></b>', '');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveNested3()
|
|
|
|
{
|
2008-06-27 20:09:14 +00:00
|
|
|
$this->assertResult('<b> <i> <u> </u> </i> </b>', '');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveNbsp()
|
|
|
|
{
|
2009-04-09 04:53:19 +00:00
|
|
|
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
|
|
|
$this->assertResult('<b> </b>', '');
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveNbspMix()
|
|
|
|
{
|
2009-04-09 04:53:19 +00:00
|
|
|
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
|
|
|
$this->assertResult('<b> </b>', '');
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testDontRemoveNbsp()
|
|
|
|
{
|
2009-04-09 04:53:19 +00:00
|
|
|
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
|
|
|
$this->assertResult('<td> </b>', "<td>\xC2\xA0</td>");
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testRemoveNbspExceptionsSpecial()
|
|
|
|
{
|
2009-04-09 04:53:19 +00:00
|
|
|
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
|
|
|
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions', 'b');
|
|
|
|
$this->assertResult('<b> </b>', "<b>\xC2\xA0</b>");
|
|
|
|
}
|
|
|
|
|
2014-08-31 10:16:30 +00:00
|
|
|
public function testRemoveIframe()
|
|
|
|
{
|
|
|
|
$this->config->set('HTML.SafeIframe', true);
|
|
|
|
$this->assertResult('<iframe></iframe>', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNoRemoveIframe()
|
|
|
|
{
|
|
|
|
$this->config->set('HTML.SafeIframe', true);
|
|
|
|
$this->assertResult('<iframe src="http://google.com"></iframe>', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testRemoveDisallowedIframe()
|
|
|
|
{
|
|
|
|
$this->config->set('HTML.SafeIframe', true);
|
|
|
|
$this->config->set('URI.SafeIframeRegexp', '%^http://www.youtube.com/embed/%');
|
|
|
|
$this->assertResult('<iframe src="http://google.com"></iframe>', '');
|
|
|
|
}
|
|
|
|
|
2008-06-27 20:09:14 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|