Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
16 | public function testSanitisation() { |
||
17 | $rawContent = '<h1>Welcome</h1><script>alert("Hello!");</script><p>Giant Robots!</p>'; |
||
18 | $safeContent = '<h1>Welcome</h1><p>Giant Robots!</p>'; |
||
19 | $field = new EditableLiteralField(); |
||
20 | |||
21 | // Test with sanitisation enabled |
||
22 | Config::inst()->update('HtmlEditorField', 'sanitise_server_side', true); |
||
23 | $field->setContent($rawContent); |
||
24 | $this->assertEquals($safeContent, $field->getContent()); |
||
25 | |||
26 | // Test with sanitisation disabled |
||
27 | Config::inst()->remove('HtmlEditorField', 'sanitise_server_side'); |
||
28 | $field->setContent($rawContent); |
||
29 | $this->assertEquals($rawContent, $field->getContent()); |
||
30 | } |
||
31 | |||
43 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.