RemoveEmptyTest.php
2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
{
public function setup()
{
parent::setup();
$this->config->set('AutoFormat.RemoveEmpty', true);
}
public function testPreserve()
{
$this->assertResult('<b>asdf</b>');
}
public function testRemove()
{
$this->assertResult('<b></b>', '');
}
public function testRemoveWithSpace()
{
$this->assertResult('<b> </b>', '');
}
public function testRemoveWithAttr()
{
$this->assertResult('<b class="asdf"></b>', '');
}
public function testRemoveIdAndName()
{
$this->assertResult('<a id="asdf" name="asdf"></a>', '');
}
public function testPreserveColgroup()
{
$this->assertResult('<colgroup></colgroup>');
}
public function testPreserveId()
{
$this->config->set('Attr.EnableID', true);
$this->assertResult('<a id="asdf"></a>');
}
public function testPreserveName()
{
$this->config->set('Attr.EnableID', true);
$this->assertResult('<a name="asdf"></a>');
}
public function testRemoveNested()
{
$this->assertResult('<b><i></i></b>', '');
}
public function testRemoveNested2()
{
$this->assertResult('<b><i><u></u></i></b>', '');
}
public function testRemoveNested3()
{
$this->assertResult('<b> <i> <u> </u> </i> </b>', '');
}
public function testRemoveNbsp()
{
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$this->assertResult('<b> </b>', '');
}
public function testRemoveNbspMix()
{
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$this->assertResult('<b> </b>', '');
}
public function testDontRemoveNbsp()
{
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$this->assertResult('<td> </b>', "<td>\xC2\xA0</td>");
}
public function testRemoveNbspExceptionsSpecial()
{
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions', 'b');
$this->assertResult('<b> </b>', "<b>\xC2\xA0</b>");
}
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>', '');
}
}
// vim: et sw=4 sts=4