X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Fxss_filter_test.php;h=5bc8e0ad3f068e0b4b8fae1d23bf31cfbee736b4;hb=c5cd5694473c1d95f9fe9ae2fa527f12cee5c4f2;hp=fe944c2a748779011ed8e1d5ed69b1e8e641a2f6;hpb=f8042d04451905486fb766c520736f4060ae9a12;p=friendica.git
diff --git a/tests/xss_filter_test.php b/tests/xss_filter_test.php
index fe944c2a74..5bc8e0ad3f 100644
--- a/tests/xss_filter_test.php
+++ b/tests/xss_filter_test.php
@@ -1,24 +1,16 @@
';
@@ -31,63 +23,40 @@ class AntiXSSTest extends PHPUnit_Framework_TestCase {
}
/**
- *autonames should be random, even length
- */
- public function testAutonameEven() {
- $autoname1=autoname(10);
- $autoname2=autoname(10);
-
- $this->assertNotEquals($autoname1, $autoname2);
- }
-
- /**
- *autonames should be random, odd length
+ *xmlify and unxmlify
*/
- public function testAutonameOdd() {
- $autoname1=autoname(9);
- $autoname2=autoname(9);
+ public function testXmlify() {
+ $text="I want to break\n this!11!";
+ $xml=xmlify($text);
+ $retext=unxmlify($text);
- $this->assertNotEquals($autoname1, $autoname2);
+ $this->assertEquals($text, $retext);
}
/**
- * try to fail autonames
+ * xmlify and put in a document
*/
- public function testAutonameNoLength() {
- $autoname1=autoname(0);
- $this->assertEquals(0, count($autoname1));
- }
-
- public function testAutonameNegativeLength() {
- $autoname1=autoname(-23);
- $this->assertEquals(0, count($autoname1));
- }
-
- // public function testAutonameMaxLength() {
- // $autoname2=autoname(PHP_INT_MAX);
- // $this->assertEquals(PHP_INT_MAX, count($autoname2));
- // }
+ public function testXmlifyDocument() {
+ $tag="I want to break";
+ $xml=xmlify($tag);
+ $text=''.$xml.'';
- public function testAutonameLength1() {
- $autoname3=autoname(1);
- $this->assertEquals(1, count($autoname3));
- }
+ $xml_parser=xml_parser_create();
+ //should be possible to parse it
+ $values=array(); $index=array();
+ $this->assertEquals(1, xml_parse_into_struct($xml_parser, $text, $values, $index));
- /**
- *xmlify and unxmlify
- */
- public function testXmlify() {
- $text="I want to break\n this!11!";
- $xml=xmlify($text); //test whether it actually may be part of a xml document
- $retext=unxmlify($text);
+ $this->assertEquals(array('TEXT'=>array(0)),
+ $index);
+ $this->assertEquals(array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),
+ $values);
- $this->assertEquals($text, $retext);
+ xml_parser_free($xml_parser);
}
/**
* test hex2bin and reverse
*/
-
public function testHex2Bin() {
$this->assertEquals(-3, hex2bin(bin2hex(-3)));
$this->assertEquals(0, hex2bin(bin2hex(0)));
@@ -95,99 +64,7 @@ class AntiXSSTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(PHP_INT_MAX, hex2bin(bin2hex(PHP_INT_MAX)));
}
- /**
- * test expand_acl
- */
- public function testExpandAclNormal() {
- $text="<1><2><3>";
- $this->assertEquals(array(1, 2, 3), expand_acl($text));
- }
-
- public function testExpandAclBigNumber() {
- $text="<1><279012><15>";
- $this->assertEquals(array(1, 279012, 15), expand_acl($text));
- }
-
- public function testExpandAclString() {
- $text="<1><279012>"; //maybe that's invalid
- $this->assertEquals(array(1, 279012, 'tt'), expand_acl($text));
- }
-
- public function testExpandAclSpace() {
- $text="<1><279 012><32>"; //maybe that's invalid
- $this->assertEquals(array(1, "279 012", "32"), expand_acl($text));
- }
-
- public function testExpandAclEmpty() {
- $text=""; //maybe that's invalid
- $this->assertEquals(array(), expand_acl($text));
- }
-
- public function testExpandAclNoBrackets() {
- $text="According to documentation, that's invalid. "; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
-
- public function testExpandAclJustOneBracket1() {
- $text="assertEquals(array(), expand_acl($text));
- }
-
- public function testExpandAclJustOneBracket2() {
- $text="Another invalid> string"; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
-
- public function testExpandAclCloseOnly() {
- $text="Another> invalid> string>"; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
-
- public function testExpandAclOpenOnly() {
- $text="assertEquals(array(), expand_acl($text));
- }
-
- public function testExpandAclNoMatching1() {
- $text=" invalid "; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
-
- public function testExpandAclNoMatching2() {
- $text="<1>2><3>";
- $this->assertEquals(array(), expand_acl($text));
- }
-
- /**
- * test attribute contains
- */
- public function testAttributeContains1() {
- $testAttr="class1 notclass2 class3";
- $this->assertTrue(attribute_contains($testAttr, "class3"));
- $this->assertFalse(attribute_contains($testAttr, "class2"));
- }
-
- /**
- * test attribute contains
- */
- public function testAttributeContains2() {
- $testAttr="class1 not-class2 class3";
- $this->assertTrue(attribute_contains($testAttr, "class3"));
- $this->assertFalse(attribute_contains($testAttr, "class2"));
- }
-
- public function testAttributeContainsEmpty() {
- $testAttr="";
- $this->assertFalse(attribute_contains($testAttr, "class2"));
- }
-
- public function testAttributeContainsSpecialChars() {
- $testAttr="--... %\$ä() /(=?}";
- $this->assertFalse(attribute_contains($testAttr, "class2"));
- }
-
//function qp, quick and dirty??
//get_mentions
//get_contact_block, bis Zeile 538
}
-?>