Skip to content

Commit d6a10bd

Browse files
committed
[TASK] Allow issue links to bitbucket
1 parent af4a164 commit d6a10bd

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

packages/typo3-docs-theme/src/Twig/TwigExtension.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,17 @@ public function getReportIssueLink(array $context): string
342342
if (str_starts_with($reportButton, 'https://gitlab.com/')) {
343343
return $reportButton;
344344
}
345+
if (str_starts_with($reportButton, 'https://bitbucket.org/')) {
346+
$reportButton = $this->enrichBitbuckedReport($reportButton, $renderContext);
347+
return $reportButton;
348+
}
345349
if ($reportButton !== '') {
346-
$this->logger->warning('For security reasons only only "report-issue" links in the guides.xml to a local page (starting with "/") or to one of these 3 plattforms are allowed: https://forge.typo3.org/ https://github.com/ https://gitlab.com/');
350+
$this->logger->warning(
351+
'For security reasons only "report-issue" links in the guides.xml
352+
to a local page (starting with "/") or to one of these 4 platforms
353+
are allowed: https://forge.typo3.org/ https://github.com/ https://gitlab.com/
354+
https://bitbucket.org/'
355+
);
347356
return '';
348357
}
349358

@@ -372,10 +381,6 @@ public function getReportIssueLink(array $context): string
372381
return '';
373382
}
374383

375-
/**
376-
* @param string $reportButton
377-
* @return string
378-
*/
379384
public function enrichGithubReport(string $reportButton, RenderContext $renderContext): string
380385
{
381386
if (str_ends_with($reportButton, '/issues')) {
@@ -389,6 +394,21 @@ public function enrichGithubReport(string $reportButton, RenderContext $renderCo
389394
return $reportButton;
390395
}
391396

397+
398+
399+
private function enrichBitbuckedReport(string $reportButton, RenderContext $renderContext): string
400+
{
401+
if (str_ends_with($reportButton, '/issues')) {
402+
$reportButton .= '/new';
403+
}
404+
if (str_ends_with($reportButton, '/new')) {
405+
$reportButton .= '?title=';
406+
$description = $this->getIssueTitle($renderContext);
407+
$reportButton .= urlencode($description);
408+
}
409+
return $reportButton;
410+
}
411+
392412
/**
393413
* @param string $reportButton
394414
* @param RenderContext $renderContext

0 commit comments

Comments
 (0)