Skip to content

Commit f91257b

Browse files
committed
api: only allow cloning questions from the same form
1 parent f18ead6 commit f91257b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/Controller/ApiController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ public function newQuestion(int $formId, ?string $type = null, ?string $subtype
570570

571571
try {
572572
$sourceQuestion = $this->questionMapper->findById($fromId);
573+
// Only allow cloning questions that belong to the same form
574+
if ($sourceQuestion->getFormId() !== $formId) {
575+
throw new OCSBadRequestException('Question doesn\'t belong to given form');
576+
}
573577
$sourceOptions = $this->optionMapper->findByQuestion($fromId);
574578
} catch (IMapperException $e) {
575579
$this->logger->debug('Could not find question');

0 commit comments

Comments
 (0)