1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
require_once(AriadneBasePath."/modules/mod_htmlcleaner.php"); |
4
|
|
|
|
5
|
|
|
class htmlcleanerTest extends AriadneBaseTest |
6
|
|
|
{ |
7
|
|
|
public function testSimple() { |
8
|
|
|
$html = '<html><head><title>test</title></head><body>testbody</body></html>'; |
9
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
10
|
|
|
$this->assertEquals($html, $clean); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
public function testFormSelectOptionSelected() { |
14
|
|
|
$html = '<body>testbody<form><select><option selected></option></select></form></body>'; |
15
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
16
|
|
|
$this->assertEquals($html, $clean); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function testFormSelectOptionEmptyAttr() { |
20
|
|
|
$html = '<body>testbody<form><a class=""></form></body>'; |
21
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
22
|
|
|
$this->assertEquals($html, $clean); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testDataAtributesDot() { |
26
|
|
|
$html = '<body>testbody<span data.dot="dot">frml</span></body>'; |
27
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
28
|
|
|
$this->assertEquals($html, $clean); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testDataAtributesUnderscore() { |
32
|
|
|
$html = '<body>testbody<span data_underscore="underscore">frml</span></body>'; |
33
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
34
|
|
|
$this->assertEquals($html, $clean); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testDataAtributesDash() { |
38
|
|
|
$html = '<body>testbody<span data-dash="dash">frml</span></body>'; |
39
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
40
|
|
|
$this->assertEquals($html, $clean); |
41
|
|
|
} |
42
|
|
|
public function testCleaningAtributesDash() { |
43
|
|
|
$html = '<body>testbody<span data-dash="dash" ar:path:=\'/some"/thing/\' >frml</span' . PHP_EOL . '></body>'; |
44
|
|
|
$prep = '<body>testbody<span data-dash="dash" ar:path:="/some"/thing/">frml</span></body>'; |
45
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
46
|
|
|
$this->assertEquals($prep, $clean); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testDataNextingImpropperHtmlEncoding() { |
50
|
|
|
$html = '<body>testbody<span data-dash="dash><">frml</span></body>'; |
51
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
52
|
|
|
$this->assertEquals($html, $clean); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testTagDash() { |
56
|
|
|
$html = '<body><hello-world>hello world</hello-world></body>'; |
57
|
|
|
$clean = htmlcleaner::cleanup($html,array()); |
58
|
|
|
$this->assertEquals($html, $clean); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
?> |
|
|
|
|
63
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.