Skip to content

Commit

Permalink
[CVE-2020-9309] Require MimeUploadValidator on userformis' File Uploa…
Browse files Browse the repository at this point in the history
…d field
  • Loading branch information
Maxime Rainville authored and Garion Herman committed Jul 12, 2020
1 parent 0c09eec commit 27228d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions _config/mimevalidator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Name: mimeuploadvalidator-userforms
---
SilverStripe\Core\Injector\Injector:
SilverStripe\Assets\Upload_Validator.userforms:
class: SilverStripe\MimeValidator\MimeUploadValidator
7 changes: 6 additions & 1 deletion code/Model/EditableFormField/EditableFileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

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;
Expand Down Expand Up @@ -96,11 +98,14 @@ public function validate()
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__);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 27228d1

Please sign in to comment.