Skip to content

Commit

Permalink
[TASK] Allow issue links to bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Oct 22, 2024
1 parent af4a164 commit d6a10bd
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions packages/typo3-docs-theme/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,17 @@ public function getReportIssueLink(array $context): string
if (str_starts_with($reportButton, 'https://gitlab.com/')) {
return $reportButton;
}
if (str_starts_with($reportButton, 'https://bitbucket.org/')) {
$reportButton = $this->enrichBitbuckedReport($reportButton, $renderContext);
return $reportButton;
}
if ($reportButton !== '') {
$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/');
$this->logger->warning(
'For security reasons only "report-issue" links in the guides.xml
to a local page (starting with "/") or to one of these 4 platforms
are allowed: https://forge.typo3.org/ https://github.com/ https://gitlab.com/
https://bitbucket.org/'
);
return '';
}

Expand Down Expand Up @@ -372,10 +381,6 @@ public function getReportIssueLink(array $context): string
return '';
}

/**
* @param string $reportButton
* @return string
*/
public function enrichGithubReport(string $reportButton, RenderContext $renderContext): string
{
if (str_ends_with($reportButton, '/issues')) {
Expand All @@ -389,6 +394,21 @@ public function enrichGithubReport(string $reportButton, RenderContext $renderCo
return $reportButton;
}



private function enrichBitbuckedReport(string $reportButton, RenderContext $renderContext): string
{
if (str_ends_with($reportButton, '/issues')) {
$reportButton .= '/new';
}
if (str_ends_with($reportButton, '/new')) {
$reportButton .= '?title=';
$description = $this->getIssueTitle($renderContext);
$reportButton .= urlencode($description);
}
return $reportButton;
}

/**
* @param string $reportButton
* @param RenderContext $renderContext
Expand Down

0 comments on commit d6a10bd

Please sign in to comment.