mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
b20f1fd59d
commit
b23c650c8a
@ -770,8 +770,9 @@ class File extends DataObject {
|
|||||||
// Extension validation
|
// Extension validation
|
||||||
// TODO Merge this with Upload_Validator
|
// TODO Merge this with Upload_Validator
|
||||||
$extension = $this->getExtension();
|
$extension = $this->getExtension();
|
||||||
if($extension && !in_array($extension, self::$allowed_extensions)) {
|
$allowed = array_map('strtolower', self::$allowed_extensions);
|
||||||
$exts = self::$allowed_extensions;
|
if($extension && !in_array(strtolower($extension), $allowed)) {
|
||||||
|
$exts = $allowed;
|
||||||
sort($exts);
|
sort($exts);
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
_t(
|
_t(
|
||||||
|
@ -60,6 +60,11 @@ class FileTest extends SapphireTest {
|
|||||||
$v = $file->validate();
|
$v = $file->validate();
|
||||||
$this->assertTrue($v->valid());
|
$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;
|
File::$allowed_extensions = $origExts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user