responseFactory->createResponse(); foreach ($this->response->getHeader()->getHttpHeaders() as $name => $value) { $response = $response->withHeader($name, $value); } $filename = $this->config->getChangeLogFilePath(); /** * Read changelog. */ // Check if the file is available, some distributions remove these. if (! @is_readable($filename)) { return $response->write(sprintf( __('The %s file is not available on this system, please visit %s for more information.'), basename($filename), 'phpmyadmin.net', )); } // Test if the file is in a compressed format if (str_ends_with($filename, '.gz')) { ob_start(); readgzfile($filename); $changelog = ob_get_clean(); } else { $changelog = file_get_contents($filename); } /** * Whole changelog in variable. */ $changelog = htmlspecialchars((string) $changelog); $githubUrl = 'https://github.com/phpmyadmin/phpmyadmin/'; $faqUrl = 'https://docs.phpmyadmin.net/en/latest/faq.html'; preg_match_all('@\n\[(\d+\.\d+\.\d+)]: (' . $githubUrl . '\S+)@', $changelog, $matches, PREG_SET_ORDER); $releaseLinks = array_column($matches, 2, 1); $changelog = (string) preg_replace_callback( '/\n## \[(\d+\.\d+\.\d+)]/', static fn (array $matches): string => "\n## [" . $matches[1] . '](' . $releaseLinks[$matches[1]] . ')', $changelog, ); $replaces = [ '/# Changes in phpMyAdmin (\d+\.\d+)/' => '

Changes in phpMyAdmin \\1

', '@\[Keep a Changelog\]\(https://keepachangelog.com/\)@' => 'Keep a Changelog', '/\n### (Added|Changed|Deprecated|Removed|Fixed|Security)/' => "\n" . '

\\1

', // Add link to release title '@\n## \[(\d+\.\d+\.\d+)\]\((' . $githubUrl . '\S+)\) \- (\d{4}|YYYY)-(\d{2}|MM)-(\d{2}|DD)\n@' => "\n" . '

\\1 \\3-\\4-\\5

' . "\n", // Add link to GitHub issues/commits '@\[(\#\d+|[a-z0-9]+)\]\((' . $githubUrl . '\S+)\)@' => '\\1', // FAQ entries '/FAQ ([0-9]+)\.([0-9a-z]+)/i' => 'FAQ \\1.\\2', // CVE/CAN entries '/((CAN|CVE)-[0-9]+-[0-9]+)/' => '\\1', // PMASA entries '/(PMASA-[0-9]+-[0-9]+)/' => '\\1', // Links target and rel '/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="', // Remove release link references '@\n\[(\d+\.\d+\.\d+)]: (' . $githubUrl . '\S+)@' => '', '/YYYY-MM-DD/' => '(not yet released)', ]; return $response->write($this->template->render('changelog', [ 'changelog' => preg_replace(array_keys($replaces), $replaces, $changelog), ])); } }