Skip to content
Snippets Groups Projects
Commit 390f4eb2 authored by Stefan Bürk's avatar Stefan Bürk Committed by Oliver Bartsch
Browse files

[BUGFIX] Use proper flags for htmlspecialchars() in "View Documentation"

PHP8.1 changed the defaults for the second argument '$flags' from
'ENT_COMPAT' to 'ENT_QUOTES | ENT_SUBSTITUTE', which changes the
behaviour if that argument was not specified. In general this is a
good change, thus leaving it unspecified and live with the stricter
default was considered as the way to go in general.

However, in the specific case for rendering the ReST files of the
changelog and view it in the install tool this change now displays
weired and malformed documentation. To mitigate this, this patch
sets explicitly the second argument to 'ENT_COMPAT | ENT_SUBSTITUTE'
to restore the old behaviour but take malformed away for preparing
the documentation content.

See: https://github.com/php/php-src/blob/85b669e56583ee5d536168db7aaffbebe9d1aff2/UPGRADING#L166

Resolves: #97073
Releases: main, 11.5
Change-Id: I3e78ef1a218fe0f09ccbcf6f4b073cf5900d42c5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73774


Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
parent 33e2f72a
Branches
Tags
No related merge requests found
......@@ -338,7 +338,7 @@ class DocumentationFile
*/
protected function parseContent(string $rstContent): string
{
$content = htmlspecialchars($rstContent);
$content = htmlspecialchars($rstContent, ENT_COMPAT | ENT_SUBSTITUTE);
$content = (string)preg_replace('/:issue:`([\d]*)`/', '<a href="https://forge.typo3.org/issues/\\1" target="_blank" rel="noreferrer">\\1</a>', $content);
$content = (string)preg_replace('/#([\d]*)/', '#<a href="https://forge.typo3.org/issues/\\1" target="_blank" rel="noreferrer">\\1</a>', $content);
$content = (string)preg_replace('/(\n([=]*)\n(.*)\n([=]*)\n)/', '', $content, 1);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment