Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.8 KiB

* tests several functions which are used to prevent xss attacks
* @package test.util
class AntiXSSTest extends PHPUnit_Framework_TestCase {
* test, that tags are escaped
public function testEscapeTags() {
$invalidstring='<submit type="button" onclick="alert(\'failed!\');" />';
$this->assertEquals('[submit type="button" onclick="alert(\'failed!\');" /]', $validstring);
$this->assertEquals("&lt;submit type=&quot;button&quot; onclick=&quot;alert('failed!');&quot; /&gt;", $escapedString);
*xmlify and unxmlify
public function testXmlify() {
$text="<tag>I want to break\n this!11!<?hard?></tag>";
$this->assertEquals($text, $retext);
* xmlify and put in a document
public function testXmlifyDocument() {
$tag="<tag>I want to break</tag>";
//should be possible to parse it
$values=array(); $index=array();
$this->assertEquals(1, xml_parse_into_struct($xml_parser, $text, $values, $index));
$this->assertEquals(array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),
* test hex2bin and reverse
public function testHex2Bin() {
$this->assertEquals(-3, hex2bin(bin2hex(-3)));
$this->assertEquals(0, hex2bin(bin2hex(0)));
$this->assertEquals(12, hex2bin(bin2hex(12)));
$this->assertEquals(PHP_INT_MAX, hex2bin(bin2hex(PHP_INT_MAX)));
//function qp, quick and dirty??
//get_contact_block, bis Zeile 538