[pLog-svn] r5927 - in plog/branches/lifetype-1.2/class: data/validator test/tests/data/validator
mark at devel.lifetype.net
mark at devel.lifetype.net
Wed Sep 12 15:10:52 EDT 2007
Author: mark
Date: 2007-09-12 15:10:51 -0400 (Wed, 12 Sep 2007)
New Revision: 5927
Modified:
plog/branches/lifetype-1.2/class/data/validator/blognamevalidator.class.php
plog/branches/lifetype-1.2/class/test/tests/data/validator/blognamevalidator_test.class.php
Log:
Fixed the BlogNameValidator() issue that we discussed in lifetype-svn mailing list.
Now, BlogNameValidator only apply the domainize() checking when subdomain function enabled.
Modified: plog/branches/lifetype-1.2/class/data/validator/blognamevalidator.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/validator/blognamevalidator.class.php 2007-09-11 19:14:37 UTC (rev 5926)
+++ plog/branches/lifetype-1.2/class/data/validator/blognamevalidator.class.php 2007-09-12 19:10:51 UTC (rev 5927)
@@ -39,9 +39,15 @@
// in addition to the other rules, the blog name won't be valid if its domainized() version
// returns empty spaces, so this is what would happen if we set a blog name of
- // things like non-characters for example
- lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
- return(( Textfilter::domainize( Textfilter::filterAllHTML( $value ))) != "" );
+ // things like non-characters for example. We only check this when subdomain enabled.
+
+ lt_include( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
+ if( Subdomains::getSubdomainsEnabled() )
+ return(( Textfilter::domainize( Textfilter::filterAllHTML( $value ))) != "" );
+ else
+ return(( Textfilter::filterAllHTML( $value )) != "" );
}
}
?>
\ No newline at end of file
Modified: plog/branches/lifetype-1.2/class/test/tests/data/validator/blognamevalidator_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/data/validator/blognamevalidator_test.class.php 2007-09-11 19:14:37 UTC (rev 5926)
+++ plog/branches/lifetype-1.2/class/test/tests/data/validator/blognamevalidator_test.class.php 2007-09-12 19:10:51 UTC (rev 5927)
@@ -1,68 +1,82 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/blognamevalidator.class.php" );
-
- /**
- * \ingroup Test
- *
- * Test case for the BlogNameValidator class
- */
- class BlogNameValidator_Test extends LifeTypeTestCase
- {
- function setUp()
- {
- // create a username validator
- $this->b = new BlogNameValidator();
- }
-
- /**
- * tests that an empty username does not validate
- */
- function testEmptyBlogname()
- {
- $this->assertFalse( $this->b->validate( "" ), "An empty blogname did not generate an error!" );
- }
-
- /**
- * tests that a forbidden username does not validate
- */
- function testForbiddenBlognameRegexps()
- {
- // get the list of forbidden words, based on our configuration settings
- lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
- $config =& Config::getConfig();
-
- // blog names starting with 'a' and ending with 'b'
- $forbiddenBlognames = $config->setValue( "forbidden_blognames", "^a.*" );
-
- $b = new BlogNameValidator();
- $this->assertFalse( $b->validate( "a-this should not work" ), "A forbidden blogname should not be accepted as valid!" );
- $this->assertTrue( $b->validate( "-this should work" ), "A valid blogname was not accepted as valid!" );
- }
-
- /**
- * tests a valid username
- */
- function testValidBlogname()
- {
- $this->assertTrue( $this->b->validate( "whatever" ), "A valid blogname was not accepted!" );
- }
-
- /**
- * test a blog name that one domainized will return empty
- */
- function testInvalidBlogName()
- {
- $this->assertFalse( $this->b->validate( "//::--", "The domainized() version of the blog name returned empty but the name was accepted as valid" ));
- }
-
- /**
- * Test a blog name whose contents if pure HTML
- */
- function testHTMLBlogNameOnly()
- {
- $this->assertFalse( $this->b->validate( "<h1></h1>", "A blog name containing HTML code only was accepted as valid" ));
- }
- }
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/blognamevalidator.class.php" );
+
+ /**
+ * \ingroup Test
+ *
+ * Test case for the BlogNameValidator class
+ */
+ class BlogNameValidator_Test extends LifeTypeTestCase
+ {
+ function setUp()
+ {
+ // create a username validator
+ $this->b = new BlogNameValidator();
+ }
+
+ /**
+ * tests that an empty username does not validate
+ */
+ function testEmptyBlogname()
+ {
+ $this->assertFalse( $this->b->validate( "" ), "An empty blogname did not generate an error!" );
+ }
+
+ /**
+ * tests that a forbidden username does not validate
+ */
+ function testForbiddenBlognameRegexps()
+ {
+ // get the list of forbidden words, based on our configuration settings
+ lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+ $config =& Config::getConfig();
+
+ // blog names starting with 'a' and ending with 'b'
+ $forbiddenBlognames = $config->setValue( "forbidden_blognames", "^a.*" );
+
+ $b = new BlogNameValidator();
+ $this->assertFalse( $b->validate( "a-this should not work" ), "A forbidden blogname should not be accepted as valid!" );
+ $this->assertTrue( $b->validate( "-this should work" ), "A valid blogname was not accepted as valid!" );
+ }
+
+ /**
+ * tests a valid username
+ */
+ function testValidBlogname()
+ {
+ $this->assertTrue( $this->b->validate( "whatever" ), "A valid blogname was not accepted!" );
+ }
+
+ /**
+ * test a blog name that one domainized will return empty
+ */
+ function testInvalidBlogName()
+ {
+ if( Subdomains::getSubdomainsEnabled() )
+ $this->assertFalse( $this->b->validate( "//::--", "The domainized() version of the blog name returned empty but the name not accepted." ));
+ else
+ $this->assertTrue( $this->b->validate( "//::--", "The domainized() version of the blog name returned empty but the name was accepted as valid." ));
+ }
+
+ /**
+ * Test a blog name whose contents if pure HTML
+ */
+ function testHTMLBlogNameOnly()
+ {
+ $this->assertFalse( $this->b->validate( "<h1></h1>", "A blog name containing HTML code only was accepted as valid" ));
+ }
+
+ /**
+ * Test a blog name with double byte characters, like Chinese
+ */
+ function testDoubleByteBlogNameOnly()
+ {
+ if( Subdomains::getSubdomainsEnabled() )
+ $this->assertFalse( $this->b->validate( "台北教會", "A blog name containing double byte characters was not accepted." ));
+ else
+ $this->assertTrue( $this->b->validate( "台北教會", "A blog name containing double byte characters was accepted as valid." ));
+ }
+ }
?>
\ No newline at end of file
More information about the pLog-svn
mailing list