Skip to content

Commit 8763c15

Browse files
jraddaouisbreker
authored andcommitted
Improve clipboard export validation, refs #13495
- Use a sfValidatorChoice to validate `objectType` param. - Check valid options before using `objectType` param as default. - Remove `objectTypre` from exception message.
1 parent d6311c8 commit 8763c15

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/qubit/modules/object/actions/exportAction.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function addField($name)
8888
break;
8989

9090
case 'objectType':
91-
if (isset($this->objectType))
91+
if (isset($this->objectType) && in_array($this->objectType, ['informationObject', 'actor', 'repository']))
9292
{
9393
$choices = array(
9494
$this->objectType => sfConfig::get('app_ui_label_'.strtolower($this->objectType))
@@ -103,7 +103,7 @@ protected function addField($name)
103103
);
104104
}
105105

106-
$this->form->setValidator('objectType', new sfValidatorString(array('required' => true)));
106+
$this->form->setValidator('objectType', new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => true)));
107107
$this->form->setWidget('objectType', new sfWidgetFormSelect(array('choices' => $choices)));
108108

109109
break;
@@ -251,7 +251,7 @@ private function getJobNameString()
251251
return 'arRepositoryCsvExportJob';
252252

253253
default:
254-
throw new sfException("Invalid object type specified: {$this->objectType}");
254+
throw new sfException("Invalid object type specified.");
255255
}
256256
}
257257
}

0 commit comments

Comments
 (0)