Skip to content

Commit

Permalink
valinor
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanashi committed Oct 14, 2023
1 parent b493c29 commit ec47f1e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
17 changes: 14 additions & 3 deletions files/lib/acp/form/FaqQuestionEditForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace wcf\acp\form;

use CuyZ\Valinor\Mapper\MappingError;
use wcf\data\faq\Question;
use wcf\data\language\item\LanguageItemList;
use wcf\http\Helper;
use wcf\system\exception\IllegalLinkException;

class FaqQuestionEditForm extends FaqQuestionAddForm
Expand All @@ -25,8 +27,17 @@ public function readParameters()
{
parent::readParameters();

if (isset($_REQUEST['id'])) {
$this->formObject = new Question((int)$_REQUEST['id']);
try {
$queryParameters = Helper::mapQueryParameters(
$_GET,
<<<'EOT'
array {
id: positive-int
}
EOT
);

$this->formObject = new Question($queryParameters['id']);
if (!$this->formObject->questionID) {
throw new IllegalLinkException();
}
Expand All @@ -40,7 +51,7 @@ public function readParameters()
$this->multiLingualAnswers[$languageItem->languageID] = $languageItem->languageItemValue;
}
}
} else {
} catch (MappingError) {
throw new IllegalLinkException();
}
}
Expand Down
17 changes: 14 additions & 3 deletions files/lib/page/FaqQuestionPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace wcf\page;

use CuyZ\Valinor\Mapper\MappingError;
use wcf\data\faq\Question;
use wcf\http\Helper;
use wcf\system\exception\IllegalLinkException;
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\WCF;
Expand All @@ -23,8 +25,17 @@ public function readParameters()
{
parent::readParameters();

if (isset($_REQUEST['id'])) {
$this->question = new Question((int)$_REQUEST['id']);
try {
$queryParameters = Helper::mapQueryParameters(
$_GET,
<<<'EOT'
array {
id: positive-int
}
EOT
);

$this->question = new Question($queryParameters['id']);
if (!$this->question->questionID || !$this->question->isAccessible()) {
throw new IllegalLinkException();
}
Expand All @@ -33,7 +44,7 @@ public function readParameters()
'dev.tkirch.wsc.faq.question',
[$this->question->questionID]
);
} else {
} catch (MappingError) {
throw new IllegalLinkException();
}
}
Expand Down

0 comments on commit ec47f1e

Please sign in to comment.