3 * tests several functions which are used to prevent xss attacks
8 require_once('include/text.php');
10 class AntiXSSTest extends PHPUnit_Framework_TestCase {
13 * test, that tags are escaped
15 public function testEscapeTags() {
16 $invalidstring='<submit type="button" onclick="alert(\'failed!\');" />';
18 $validstring=notags($invalidstring);
19 $escapedString=escape_tags($invalidstring);
21 $this->assertEquals('[submit type="button" onclick="alert(\'failed!\');" /]', $validstring);
22 $this->assertEquals("<submit type="button" onclick="alert('failed!');" />", $escapedString);
28 public function testXmlify() {
29 $text="<tag>I want to break\n this!11!<?hard?></tag>";
30 $xml=xmlify($text); //test whether it actually may be part of a xml document
31 $retext=unxmlify($text);
33 $this->assertEquals($text, $retext);
37 * test hex2bin and reverse
39 public function testHex2Bin() {
40 $this->assertEquals(-3, hex2bin(bin2hex(-3)));
41 $this->assertEquals(0, hex2bin(bin2hex(0)));
42 $this->assertEquals(12, hex2bin(bin2hex(12)));
43 $this->assertEquals(PHP_INT_MAX, hex2bin(bin2hex(PHP_INT_MAX)));
46 //function qp, quick and dirty??
48 //get_contact_block, bis Zeile 538