[pLog-svn] r6276 - in plog/branches/lifetype-1.2/class: data/validator misc template test/tests/misc

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat Mar 29 12:57:04 EDT 2008


Author: jondaley
Date: 2008-03-29 12:57:04 -0400 (Sat, 29 Mar 2008)
New Revision: 6276

Modified:
   plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php
   plog/branches/lifetype-1.2/class/misc/integritychecker.class.php
   plog/branches/lifetype-1.2/class/template/templatesandbox.class.php
   plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php
Log:
added case insensitive checking.  Might not work on windows (ie. is FNM_CASEFOLD defined?)

Modified: plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php	2008-03-29 16:50:12 UTC (rev 6275)
+++ plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php	2008-03-29 16:57:04 UTC (rev 6276)
@@ -81,7 +81,7 @@
             // check if the filename extension is forbidden or not
             $fileName = basename($upload->getFileName());
             foreach( explode( " ", $forbiddenFilesStr ) as $file ) {
-            	if( Glob::myFnmatch( $file, $fileName )) {
+            	if( Glob::myFnmatch( $file, $fileName, FNM_CASEFOLD )) {
                 	return UPLOAD_VALIDATOR_ERROR_FORBIDDEN_EXTENSION;
                 }
             }
@@ -99,7 +99,7 @@
             // check if the filename extension is one of the allowed ones or not
             $fileName = basename($upload->getFileName());
             foreach( explode( " ", $allowedFilesStr ) as $file ) {
-            	if( Glob::myFnmatch( $file, $fileName )) {
+            	if( Glob::myFnmatch( $file, $fileName, FNM_CASEFOLD )) {
 //					print("it's a valid file!");
                 	return true;
                 }

Modified: plog/branches/lifetype-1.2/class/misc/integritychecker.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/misc/integritychecker.class.php	2008-03-29 16:50:12 UTC (rev 6275)
+++ plog/branches/lifetype-1.2/class/misc/integritychecker.class.php	2008-03-29 16:57:04 UTC (rev 6276)
@@ -84,7 +84,7 @@
 			
 			$result = false;
 			foreach( $ignore as $pattern ) {
-				if( Glob::myFnMatch( $pattern, $file )) {
+				if( Glob::myFnMatch( $pattern, $file, FNM_CASEFOLD )) {
 					$result = true;
 					break;					
 				}

Modified: plog/branches/lifetype-1.2/class/template/templatesandbox.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/template/templatesandbox.class.php	2008-03-29 16:50:12 UTC (rev 6275)
+++ plog/branches/lifetype-1.2/class/template/templatesandbox.class.php	2008-03-29 16:57:04 UTC (rev 6276)
@@ -48,7 +48,7 @@
             // otherwise, turn the thing into an array and go through all of them
 			lt_include( PLOG_CLASS_PATH.'class/misc/glob.class.php' );			
             foreach( explode( " ", $forbiddenFilesStr ) as $file ) {
-                $files = Glob::myGlob( $folder, $file );
+                $files = Glob::myGlob( $folder, $file, FNM_CASEFOLD );
                 if( count($files) > 0 )
                 	return false;
             }

Modified: plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php	2008-03-29 16:50:12 UTC (rev 6275)
+++ plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php	2008-03-29 16:57:04 UTC (rev 6276)
@@ -17,6 +17,10 @@
 			
 			// valid match
 			$this->assertTrue( Glob::myFnMatch( "*index.template.*", "index.template.php" ));			
+
+                // case sensitive checking
+			$this->assertTrue( Glob::myFnMatch( "*index.template.PHP", "index.template.php", FNM_CASEFOLD ));
+			$this->assertFalse( Glob::myFnMatch( "*index.template.PHP", "index.template.php"));
 		}		
 	}
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list