[pLog-svn] r7147 - in plog/branches/lifetype-1.2/class: data test/tests/data
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Wed Oct 26 18:05:41 EDT 2011
Author: jondaley
Date: 2011-10-26 18:05:41 -0400 (Wed, 26 Oct 2011)
New Revision: 7147
Modified:
plog/branches/lifetype-1.2/class/data/textfilter.class.php
plog/branches/lifetype-1.2/class/test/tests/data/textfilter_test.class.php
Log:
move the 'WP tests' out of balance tags, so they get called before strip_tags. some more tests and checks
Modified: plog/branches/lifetype-1.2/class/data/textfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/textfilter.class.php 2011-10-26 21:45:36 UTC (rev 7146)
+++ plog/branches/lifetype-1.2/class/data/textfilter.class.php 2011-10-26 22:05:41 UTC (rev 7147)
@@ -65,12 +65,19 @@
$config =& Config::getConfig();
$htmlAllowedTags = $config->getValue( "html_allowed_tags_in_comments" );
}
-
- $tmp = strip_tags( $string, $htmlAllowedTags );
- $tmp = TextFilter::balanceTags($tmp);
- $filteredString = TextFilter::filterJavaScript( $tmp );
- return $filteredString;
+ // WP bug fix for comments - in case you REALLY meant to type '< !--'
+ $string = str_replace('< !--', '< !--', $string);
+ // WP bug fix for LOVE <3 (and other situations with '<' before a number)
+ $string = preg_replace('#<([0-9]+)#', '<$1', $string);
+ // some nice people might like to use "< >" without meaning to do HTML?
+ $string = preg_replace('#<( *)>#', '<$1>', $string);
+
+ $string = strip_tags( $string, $htmlAllowedTags );
+ $string = TextFilter::balanceTags($string);
+ $string = TextFilter::filterJavaScript( $string );
+
+ return $string;
}
/**
@@ -294,14 +301,12 @@
*/
function balanceTags($text)
{
- $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
-
- # WP bug fix for comments - in case you REALLY meant to type '< !--'
- $text = str_replace('< !--', '< !--', $text);
- # WP bug fix for LOVE <3 (and other situations with '<' before a number)
- $text = preg_replace('#<([0-9]{1})#', '<$1', $text);
-
- while (preg_match("/<(\/?\w*)\s*([^>]*)>/",$text,$regex)) {
+ $tagstack = array();
+ $stacksize = 0;
+ $tagqueue = '';
+ $newtext = '';
+
+ while (preg_match("#<(/?\w*)\s*([^>]*)>#",$text,$regex)) {
$newtext .= $tagqueue;
$i = strpos($text,$regex[0]);
Modified: plog/branches/lifetype-1.2/class/test/tests/data/textfilter_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/data/textfilter_test.class.php 2011-10-26 21:45:36 UTC (rev 7146)
+++ plog/branches/lifetype-1.2/class/test/tests/data/textfilter_test.class.php 2011-10-26 22:05:41 UTC (rev 7147)
@@ -136,20 +136,19 @@
"some <a>html</a><b>is</b>not<p>allowed</p>",
"non-html like < is ok" => "non-html like < is ok",
"non-html like > is ok" => "non-html like > is ok",
+ "<3 is fine." => "<3 is fine.",
+ "so is <31231." => "so is <31231.",
"Unclosed tags should be <i> closed" => "Unclosed tags should be <i> closed</i>",
- "NULL tags <> should be removed?" => "NULL tags should be removed?",
- "Empty tags < > should be not crash." => "Empty tags < > should be not crash.",
+ "Unclosed tags should be <p>closed" => "Unclosed tags should be <p>closed</p>",
+ "NULL tags <> shouldn't be removed" => "NULL tags <> shouldn't be removed",
+ "Empty tags < > should not crash." => "Empty tags < > should not crash.",
+ "Weird tags <asd > aren't ok." => "Weird tags aren't ok.",
"Other HTML is not <h1> <p>allowed</p></h1>" => "Other HTML is not <p>allowed</p>",
-// "&" => "&",
-// "test" => "test",
+ "&" => "&",
);
foreach( $tests as $input => $output ) {
- // check that the input is equal to the output after processing it with TextFilter::htmlDecode
$this->assertEquals( $output, TextFilter::filterHtml( $input ) );
- // and that htmlDecode and filterHTMLEntities are really the opposite of each other
-// $this->assertEquals( $input, Textfilter::htmlDecode( TextFilter::filterHTMLEntities( $input )));
-// $this->assertEquals( $output, Textfilter::htmlDecode( TextFilter::filterHTMLEntities( $output )));
}
}
More information about the pLog-svn
mailing list