[pLog-svn] r4071 - in plog/branches/lifetype-1.1.1/class: data
test/tests/data
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Oct 1 19:41:37 GMT 2006
Author: oscar
Date: 2006-10-01 19:41:36 +0000 (Sun, 01 Oct 2006)
New Revision: 4071
Modified:
plog/branches/lifetype-1.1.1/class/data/textfilter.class.php
plog/branches/lifetype-1.1.1/class/test/tests/data/textfilter_test.class.php
Log:
dots ('.') should not be allowed as part of domains, or else things like 'http://name.surname.blogsite.com' would be allowed
Modified: plog/branches/lifetype-1.1.1/class/data/textfilter.class.php
===================================================================
--- plog/branches/lifetype-1.1.1/class/data/textfilter.class.php 2006-10-01 19:28:23 UTC (rev 4070)
+++ plog/branches/lifetype-1.1.1/class/data/textfilter.class.php 2006-10-01 19:41:36 UTC (rev 4071)
@@ -424,16 +424,8 @@
return $string;
}
-
/**
* Given a string, convert it into something that can be used in the domain part of a URL
- * change spaces and underscores to hyphens - then call our regular urlize function for
- * the rest.
- *
- * @param string The string that we wish to convert into something that can be used as a URL
- */
- /**
- * Given a string, convert it into something that can be used in the domain part of a URL
* (it probably doesn't work very
* well with non iso-8859-X strings) It will remove the following characters:
*
@@ -457,12 +449,12 @@
// replace some characters to similar ones
// underscores aren't allowed in domain names according to rfc specs, and
// cause trouble in some browsers, particularly with cookies.
- $search = array('_',' ','ä','ö','ü','é','è','à','ç','à','è','ì','ò','ù','á','é','í','ó','ú','ë','ï');
- $replace = array('-','-','a','o','u','e','e','a','c','a','e','i','o','u','a','e','i','o','u','e','i');
+ $search = array('_',' ', '.', 'ä','ö','ü','é','è','à','ç','à','è','ì','ò','ù','á','é','í','ó','ú','ë','ï' );
+ $replace = array('-','-', '-', 'a','o','u','e','e','a','c','a','e','i','o','u','a','e','i','o','u','e','i' );
$string = str_replace($search, $replace, $string);
// and everything that is still left that hasn't been replaced/encoded, throw it away
- $string = preg_replace( '/[^a-z0-9.-]/', '', $string );
+ $string = preg_replace( '/[^a-z0-9-]/', '', $string );
$string = trim($string, "-.");
return $string;
Modified: plog/branches/lifetype-1.1.1/class/test/tests/data/textfilter_test.class.php
===================================================================
--- plog/branches/lifetype-1.1.1/class/test/tests/data/textfilter_test.class.php 2006-10-01 19:28:23 UTC (rev 4070)
+++ plog/branches/lifetype-1.1.1/class/test/tests/data/textfilter_test.class.php 2006-10-01 19:41:36 UTC (rev 4071)
@@ -43,5 +43,26 @@
$this->assertEquals( $output, $result );
}
}
+
+ /**
+ * Verifies the domainize() method
+ */
+ function testDomainize()
+ {
+ // set of input values and their expected output
+ $tests = Array(
+ "test blog" => "test-blog",
+ "test-blog" => "test-blog",
+ "test-blog" => "test-blog",
+ "test.blog" => "test-blog",
+ "??test//blog" => "testblog",
+ "==================test blog" => "test-blog"
+ );
+
+ foreach( $tests as $input => $output ) {
+ $result = $this->tf->domainize( $input );
+ $this->assertEquals( $output, $result );
+ }
+ }
}
?>
\ No newline at end of file
More information about the pLog-svn
mailing list