Skip to content

Commit a6a8961

Browse files
committed
fix(api): only allow cloning questions from the same form
1 parent c385eee commit a6a8961

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
@@ -562,6 +562,10 @@ public function newQuestion(int $formId, ?string $type = null, ?string $subtype
562562

563563
try {
564564
$sourceQuestion = $this->questionMapper->findById($fromId);
565+
// Only allow cloning questions that belong to the same form
566+
if ($sourceQuestion->getFormId() !== $formId) {
567+
throw new OCSBadRequestException('Question doesn\'t belong to given form');
568+
}
565569
$sourceOptions = $this->optionMapper->findByQuestion($fromId);
566570
} catch (IMapperException $e) {
567571
$this->logger->debug('Could not find question');

0 commit comments

Comments
 (0)