Merge pull request #3576 from tractorcow/pulls/3.1/upload-attach

BUG File attach handler is no longer accessible if attachment is disallowed or disabled
This commit is contained in:
Loz Calver 2014-10-25 23:12:03 +01:00
commit 2176a6dea8
2 changed files with 7 additions and 0 deletions

View File

@ -1089,6 +1089,7 @@ class UploadField extends FileField {
* @return UploadField_ItemHandler
*/
public function handleSelect(SS_HTTPRequest $request) {
if(!$this->canAttachExisting()) return $this->httpError(403);
return UploadField_SelectHandler::create($this, $this->getFolderName());
}

View File

@ -621,6 +621,12 @@ class UploadFieldTest extends FunctionalTest {
(bool)$parser->getBySelector('#CanAttachExistingFalseField .ss-uploadfield-fromfiles'),
'Removes "From files" button'
);
// Test requests to select files have the correct given permission
$response2 = $this->get('UploadFieldTest_Controller/Form/field/CanAttachExistingFalseField/select');
$this->assertEquals(403, $response2->getStatusCode());
$response3 = $this->get('UploadFieldTest_Controller/Form/field/HasOneFile/select');
$this->assertEquals(200, $response3->getStatusCode());
}
public function testSelect() {