[pLog-svn] r5287 - in plog/branches/lifetype-1.2/class: data test/tests/data
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Sat Apr 7 16:38:01 EDT 2007
Author: jondaley
Date: 2007-04-07 16:38:00 -0400 (Sat, 07 Apr 2007)
New Revision: 5287
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:
fixed bug in last checkin, need to escape separator if it is a hyphen. updated test to check urlize, as well as check some other cases
Modified: plog/branches/lifetype-1.2/class/data/textfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/textfilter.class.php 2007-04-07 20:27:04 UTC (rev 5286)
+++ plog/branches/lifetype-1.2/class/data/textfilter.class.php 2007-04-07 20:38:00 UTC (rev 5287)
@@ -451,13 +451,11 @@
// and everything that is still left that hasn't been
// replaced/encoded, throw it away
- $good_characters = "a-z0-9.".$separator;
+ // NOTE: need double backslash to pass the escape to preg_replace
+ $good_characters = "a-z0-9.\\".$separator;
if(!$domainize){
- // need double backslash to pass the escape to
- // preg_replace on the next line
- $good_characters .= " _\\-";
+ $good_characters .= "_\\-";
}
-
$string = preg_replace( '/[^'.$good_characters.']/', '', $string );
// remove doubled separators
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 2007-04-07 20:27:04 UTC (rev 5286)
+++ plog/branches/lifetype-1.2/class/test/tests/data/textfilter_test.class.php 2007-04-07 20:38:00 UTC (rev 5287)
@@ -56,7 +56,7 @@
// set of input values and their expected output
$tests = Array(
- "test blog" => "test{$sep}blog",
+ "TesT BlOg" => "test{$sep}blog",
"test-blog" => "test{$sep}blog",
"test_blog" => "test{$sep}blog",
"test.blog" => "test.blog",
@@ -70,8 +70,36 @@
$this->assertEquals( $output, $result, "input was: $input" );
}
}
-
+
/**
+ * Verifies the urlize() method
+ */
+ function testUrlize()
+ {
+ // load the value of the default separator
+ $config =& Config::getConfig();
+ $sep = $config->getValue( "urlize_word_separator", URLIZE_WORD_SEPARATOR_DEFAULT );
+
+ // set of input values and their expected output
+ $tests = Array(
+ "teSt blog" => "test{$sep}blog",
+ "test-blog" => "test-blog",
+ "test_blog" => "test_blog",
+ "test.blog" => "test.blog",
+ "??test//blog" => "test{$sep}blog",
+ "==================test blog" => "test{$sep}blog",
+ "this.has.dots_and-hyphens----and spaces " => "this.has.dots_and-hyphens{$sep}and{$sep}spaces",
+ "multiple__underscores______" => "multiple__underscores______"
+ );
+
+ foreach( $tests as $input => $output ) {
+ $result = $this->tf->urlize( $input );
+ $this->assertEquals( $output, $result, "input was: $input" );
+ }
+ }
+
+
+ /**
* tests the htmlDecode() method
*/
function testHtmlDecode()
More information about the pLog-svn
mailing list