Skip to content

Commit 42cbe08

Browse files
committed
fix: add max depth limit to source_page_uid ancestor chain traversal
Prevent unbounded while loop when following the source_page_uid chain to find briefing data from ancestor pages. Limits traversal to 10 levels, which is more than sufficient for realistic re-generation chains.
1 parent 39b5044 commit 42cbe08

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Classes/Controller/Backend/LandingPageWizardController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ public function generationInfoAction(ServerRequestInterface $request): ResponseI
519519
if ($briefingAnswers === [] && is_numeric($sourcePageUid) && (int) $sourcePageUid > 0) {
520520
$ancestorUid = (int) $sourcePageUid;
521521
$visited = [$pageUid];
522-
while ($ancestorUid > 0 && !in_array($ancestorUid, $visited, true)) {
522+
$maxDepth = 10;
523+
while ($ancestorUid > 0 && !in_array($ancestorUid, $visited, true) && $maxDepth-- > 0) {
523524
$visited[] = $ancestorUid;
524525
$ancestorQb = $this->connectionPool->getQueryBuilderForTable('pages');
525526
$ancestorQb->getRestrictions()->removeByType(

0 commit comments

Comments
 (0)