BUGFIX Case insensitive extension checks in File::validate() (fixes #5781, thanks simon_w)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@107539 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-07-06 03:08:57 +00:00 committed by Sam Minnee
parent b20f1fd59d
commit b23c650c8a
2 changed files with 8 additions and 2 deletions

View File

@ -770,8 +770,9 @@ class File extends DataObject {
// Extension validation
// TODO Merge this with Upload_Validator
$extension = $this->getExtension();
if($extension && !in_array($extension, self::$allowed_extensions)) {
$exts = self::$allowed_extensions;
$allowed = array_map('strtolower', self::$allowed_extensions);
if($extension && !in_array(strtolower($extension), $allowed)) {
$exts = $allowed;
sort($exts);
$message = sprintf(
_t(

View File

@ -60,6 +60,11 @@ class FileTest extends SapphireTest {
$v = $file->validate();
$this->assertTrue($v->valid());
// Capital extension is valid as well
$file->Name = 'asdf.TXT';
$v = $file->validate();
$this->assertTrue($v->valid());
File::$allowed_extensions = $origExts;
}