added test blueprints, fixed? encoding issues
This commit is contained in:
		
					parent
					
						
							
								dd9432903d
							
						
					
				
			
			
				commit
				
					
						fbc017cdba
					
				
			
		
					 2 changed files with 150 additions and 10 deletions
				
			
		
							
								
								
									
										140
									
								
								tests/xss_filter_tests.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								tests/xss_filter_tests.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,140 @@
 | 
			
		|||
<?php
 | 
			
		||||
/**
 | 
			
		||||
* Tests, without pHPUnit by now
 | 
			
		||||
* @package test.util
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
require_once(text.php); 
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* test no tags
 | 
			
		||||
*/
 | 
			
		||||
$invalidstring='<submit type="button" onclick="alert(\'failed!\');" />'
 | 
			
		||||
 | 
			
		||||
$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="<tag>I want to break\n this!11!<?hard?></tag>"
 | 
			
		||||
$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><tt>"; //maybe that's invalid
 | 
			
		||||
assert(array(1, 279012, "tt"), $text); 
 | 
			
		||||
 | 
			
		||||
$text="<1><279 012><tt>"; //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="<Another invalid string"; //should be invalid
 | 
			
		||||
assert(array(), $text); 
 | 
			
		||||
 | 
			
		||||
$text="Another invalid> string"; //should be invalid
 | 
			
		||||
assert(array(), $text); 
 | 
			
		||||
 | 
			
		||||
$text="Another> invalid> string>"; //should be invalid
 | 
			
		||||
assert(array(), $text); 
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* test attribute contains
 | 
			
		||||
*/
 | 
			
		||||
$testAttr="class1 notclass2 class3"; 
 | 
			
		||||
assertTrue(attribute_contains($testAttr, "class3")); 
 | 
			
		||||
assertFalse(attribute_contains($testAttr, "class2")); 
 | 
			
		||||
 | 
			
		||||
$testAttr=""; 
 | 
			
		||||
assertFalse(attribute_contains($testAttr, "class2")); 
 | 
			
		||||
 | 
			
		||||
$testAttr="--... %$§() /(=?}"; 
 | 
			
		||||
assertFalse(attribute_contains($testAttr, "class2")); 
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* test get_tags
 | 
			
		||||
*/
 | 
			
		||||
$text="hi @Mike, I'm just writing #test_cases, "; 
 | 
			
		||||
$text.=" so @somebody@friendica.com may change #things. Of course I "; 
 | 
			
		||||
$text.="look for a lot of #pitfalls, like #tags at the end of a sentence "; 
 | 
			
		||||
$text.="@comment. I hope noone forgets about @fullstops.because that might"; 
 | 
			
		||||
$text.=" break #things. @Mike@campino@friendica.eu is also #nice, isn't it? "; 
 | 
			
		||||
$text.="Now, add a @first_last tag. "
 | 
			
		||||
//check whether this are all variants (no, auto-stuff is missing). 
 | 
			
		||||
 | 
			
		||||
$tags=get_tags($text); 
 | 
			
		||||
 | 
			
		||||
assert("@Mike", $tags[0]); 
 | 
			
		||||
assert("#test_cases", $tags[1]); 
 | 
			
		||||
assert("@somebody@friendica.com", $tags[2]); 
 | 
			
		||||
assert("#things", $tags[3]); 
 | 
			
		||||
assert("#pitfalls", $tags[4]); 
 | 
			
		||||
assert("#tags", $tags[5]); 
 | 
			
		||||
assert("@comment", $tags[6]); 
 | 
			
		||||
assert("@fullstops", $tags[7]); 
 | 
			
		||||
assert("#things", $tags[8]); 
 | 
			
		||||
assert("@Mike", $tags[9]); 
 | 
			
		||||
assert("@campino@friendica.eu", $tags[10]); 
 | 
			
		||||
assert("#nice", $tags[11]); 
 | 
			
		||||
assert("@first_last", $tags[12]); 
 | 
			
		||||
 | 
			
		||||
$tags=get_tags(""); 
 | 
			
		||||
assert(0, count($tags)); 
 | 
			
		||||
 | 
			
		||||
//function qp, quick and dirty??
 | 
			
		||||
//get_mentions
 | 
			
		||||
//get_contact_block, bis Zeile 538
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ function string_plural_select_de($n){
 | 
			
		|||
	return ($n != 1);
 | 
			
		||||
}
 | 
			
		||||
;
 | 
			
		||||
$a->strings["Post successful."] = "Beitrag erfolgreich veröffentlicht.";
 | 
			
		||||
$a->strings["Post successful."] = "Beitrag erfolgreich veröffentlicht.";
 | 
			
		||||
$a->strings["[Embedded content - reload page to view]"] = "[Eingebetteter Inhalt - Seite neu laden zum Betrachten]";
 | 
			
		||||
$a->strings["Contact settings applied."] = "Einstellungen zum Kontakt angewandt.";
 | 
			
		||||
$a->strings["Contact update failed."] = "Konnte den Kontakt nicht aktualisieren.";
 | 
			
		||||
| 
						 | 
				
			
			@ -12,15 +12,15 @@ $a->strings["Permission denied."] = "Zugriff verweigert.";
 | 
			
		|||
$a->strings["Contact not found."] = "Kontakt nicht gefunden.";
 | 
			
		||||
$a->strings["Repair Contact Settings"] = "Kontakt-Einstellungen reparieren";
 | 
			
		||||
$a->strings["<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working."] = "<strong>ACHTUNG: Das sind Experten-Einstellungen!</strong> Wenn Du etwas falsches eingibst, funktioniert die Kommunikation mit diesem Kontakt evtl. nicht mehr.";
 | 
			
		||||
$a->strings["Please use your browser 'Back' button <strong>now</strong> if you are uncertain what to do on this page."] = "Bitte nutze den Zurück-Button deines Browsers <strong>jetzt</strong>, wenn du dir unsicher bist, was auf dieser Seite gemacht wird.";
 | 
			
		||||
$a->strings["Return to contact editor"] = "Zurück zum Kontakteditor";
 | 
			
		||||
$a->strings["Please use your browser 'Back' button <strong>now</strong> if you are uncertain what to do on this page."] = "Bitte nutze den Zurück-Button deines Browsers <strong>jetzt</strong>, wenn du dir unsicher bist, was auf dieser Seite gemacht wird.";
 | 
			
		||||
$a->strings["Return to contact editor"] = "Zurück zum Kontakteditor";
 | 
			
		||||
$a->strings["Name"] = "Name";
 | 
			
		||||
$a->strings["Account Nickname"] = "Account-Spitzname";
 | 
			
		||||
$a->strings["@Tagname - overrides Name/Nickname"] = "@Tagname - überschreibt Name/Spitzname";
 | 
			
		||||
$a->strings["@Tagname - overrides Name/Nickname"] = "@Tagname - überschreibt Name/Spitzname";
 | 
			
		||||
$a->strings["Account URL"] = "Account-URL";
 | 
			
		||||
$a->strings["Friend Request URL"] = "URL für Freundschaftsanfragen";
 | 
			
		||||
$a->strings["Friend Confirm URL"] = "URL für Bestätigungen von Freundschaftsanfragen";
 | 
			
		||||
$a->strings["Notification Endpoint URL"] = "URL-Endpunkt für Benachrichtigungen";
 | 
			
		||||
$a->strings["Friend Request URL"] = "URL für Freundschaftsanfragen";
 | 
			
		||||
$a->strings["Friend Confirm URL"] = "URL für Bestätigungen von Freundschaftsanfragen";
 | 
			
		||||
$a->strings["Notification Endpoint URL"] = "URL-Endpunkt für Benachrichtigungen";
 | 
			
		||||
$a->strings["Poll/Feed URL"] = "Pull/Feed-URL";
 | 
			
		||||
$a->strings["New photo from this URL"] = "Neues Foto von dieser URL";
 | 
			
		||||
$a->strings["Submit"] = "Senden";
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ $a->strings["Help:"] = "Hilfe:";
 | 
			
		|||
$a->strings["Help"] = "Hilfe";
 | 
			
		||||
$a->strings["Not Found"] = "Nicht gefunden";
 | 
			
		||||
$a->strings["Page not found."] = "Seite nicht gefunden.";
 | 
			
		||||
$a->strings["File exceeds size limit of %d"] = "Die Datei ist größer als das erlaubte Limit von %d";
 | 
			
		||||
$a->strings["File exceeds size limit of %d"] = "Die Datei ist größer als das erlaubte Limit von %d";
 | 
			
		||||
$a->strings["File upload failed."] = "Hochladen der Datei fehlgeschlagen.";
 | 
			
		||||
$a->strings["Friend suggestion sent."] = "Kontaktvorschlag gesendet.";
 | 
			
		||||
$a->strings["Suggest Friends"] = "Kontakte vorschlagen";
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ $a->strings["link to source"] = "Link zum Originalbeitrag";
 | 
			
		|||
$a->strings["Events"] = "Veranstaltungen";
 | 
			
		||||
$a->strings["Create New Event"] = "Neue Veranstaltung erstellen";
 | 
			
		||||
$a->strings["Previous"] = "Vorherige";
 | 
			
		||||
$a->strings["Next"] = "Nächste";
 | 
			
		||||
$a->strings["Next"] = "Nächste";
 | 
			
		||||
$a->strings["hour:minute"] = "Stunde:Minute";
 | 
			
		||||
$a->strings["Event details"] = "Veranstaltungsdetails";
 | 
			
		||||
$a->strings["Format is %s %s. Starting date and Description are required."] = "Format ist %s %s. Anfangsdatum und Beschreibung sind notwendig.";
 | 
			
		||||
| 
						 | 
				
			
			@ -643,7 +643,7 @@ $a->strings["Site name"] = "Seitenname";
 | 
			
		|||
$a->strings["Banner/Logo"] = "Banner/Logo";
 | 
			
		||||
$a->strings["System language"] = "Systemsprache";
 | 
			
		||||
$a->strings["System theme"] = "Systemweites Thema";
 | 
			
		||||
$a->strings["Maximum image size"] = "Maximale Größe von Bildern";
 | 
			
		||||
$a->strings["Maximum image size"] = "Maximale Größe von Bildern";
 | 
			
		||||
$a->strings["Register policy"] = "Registrierungsmethode";
 | 
			
		||||
$a->strings["Register text"] = "Registrierungstext";
 | 
			
		||||
$a->strings["Accounts abandoned after x days"] = "Accounts gelten nach x Tagen als unbenutzt";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue