From fbc017cdba81fa7b159bca5fd0b3a4fb4885c5ad Mon Sep 17 00:00:00 2001 From: Alexander Kampmann Date: Mon, 5 Mar 2012 22:22:10 +0100 Subject: added test blueprints, fixed? encoding issues --- tests/xss_filter_tests.php | 140 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 tests/xss_filter_tests.php (limited to 'tests') diff --git a/tests/xss_filter_tests.php b/tests/xss_filter_tests.php new file mode 100644 index 000000000..2d29e390a --- /dev/null +++ b/tests/xss_filter_tests.php @@ -0,0 +1,140 @@ +' + +$validstring=notags($invalidstring); +$escapedString=escape_tags($invalidstring); + +assert("[submit type="button" onclick="alert(\'failed!\');" /]", $validstring); +assert("what ever", $escapedString); + +/** +*autonames should be random, even length +*/ +$autoname1=autoname(10); +$autoname2=autoname(10); + +assertNotEquals($autoname1, $autoname2); + +/** +*autonames should be random, odd length +*/ +$autoname1=autoname(9); +$autoname2=autoname(9); + +assertNotEquals($autoname1, $autoname2); + +/** +* try to fail autonames +*/ +$autoname1=autoname(0); +$autoname2=autoname(MAX_VALUE); +$autoname3=autoname(1); +assert(count($autoname1), 0); +assert(count($autoname2), MAX_VALUE); +assert(count($autoname3), 1); + +/** +*xmlify and unxmlify +*/ +$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); + +assert($text, $retext); + +/** +* test hex2bin and reverse +*/ + +assert(-3, hex2bin(bin2hex(-3))); +assert(0, hex2bin(bin2hex(0))); +assert(12, hex2bin(bin2hex(12))); +assert(MAX_INT, hex2bin(bin2hex(MAX_INT))); + +/** +* test expand_acl +*/ +$text="<1><2><3>"; +assert(array(1, 2, 3), $text); + +$text="<1><279012><15>"; +assert(array(1, 279012, 15), $text); + +$text="<1><279012>"; //maybe that's invalid +assert(array(1, 279012, "tt"), $text); + +$text="<1><279 012>"; //maybe that's invalid +assert(array(1, "279 012", "tt"), $text); + +$text=""; //maybe that's invalid +assert(array(), $text); + +$text="According to documentation, that's invalid. "; //should be invalid +assert(array(), $text); + +$text=" -- cgit v1.2.3