summaryrefslogtreecommitdiffstats
path: root/tests/lib/template.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/template.php')
-rw-r--r--tests/lib/template.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/lib/template.php b/tests/lib/template.php
index b4f1a4c4053..b3d0975b793 100644
--- a/tests/lib/template.php
+++ b/tests/lib/template.php
@@ -28,13 +28,23 @@ class Test_TemplateFunctions extends PHPUnit_Framework_TestCase {
}
public function testP() {
- // FIXME: do we need more testcases?
- $htmlString = "<script>alert('xss');</script>";
+ $badString = '<img onload="alert(1)" />';
+ ob_start();
+ p($badString);
+ $result = ob_get_clean();
+ $this->assertEquals('&lt;img onload=&quot;alert(1)&quot; /&gt;', $result);
+
+ $badString = "<script>alert('Hacked!');</script>";
ob_start();
- p($htmlString);
+ p($badString);
$result = ob_get_clean();
+ $this->assertEquals('&lt;script&gt;alert(&#039;Hacked!&#039;);&lt;/script&gt;', $result);
- $this->assertEquals("&lt;script&gt;alert(&#039;xss&#039;);&lt;/script&gt;", $result);
+ $goodString = 'This is a good string without HTML.';
+ ob_start();
+ p($goodString);
+ $result = ob_get_clean();
+ $this->assertEquals('This is a good string without HTML.', $result);
}
public function testPNormalString() {