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
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.