[CVE-2020-9309] Require MimeUploadValidator on userformis' File Upload field

This commit is contained in:
Maxime Rainville 2020-05-11 13:55:33 +12:00 committed by Garion Herman
parent 0c09eec6f8
commit 27228d12af
3 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
Name: mimeuploadvalidator-userforms
---
SilverStripe\Core\Injector\Injector:
SilverStripe\Assets\Upload_Validator.userforms:
class: SilverStripe\MimeValidator\MimeUploadValidator

View File

@ -4,7 +4,9 @@ namespace SilverStripe\UserForms\Model\EditableFormField;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Assets\Upload_Validator;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\FileField;
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\NumericField;
@ -96,11 +98,14 @@ class EditableFileField extends EditableFormField
return $result;
}
public function getFormField()
{
$field = FileField::create($this->Name, $this->Title ?: false)
->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate(__CLASS__);
->setTemplate(__CLASS__)
->setValidator(Injector::inst()->get(Upload_Validator::class . '.userforms'));
$field->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate(__CLASS__);

View File

@ -33,7 +33,8 @@
"silverstripe/cms": "^4.0",
"symbiote/silverstripe-gridfieldextensions": "^3.1",
"silverstripe/segment-field": "^2.0",
"silverstripe/versioned": "^1.0"
"silverstripe/versioned": "^1.0",
"silverstripe/mimevalidator": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",