diff --git a/typo3/sysext/core/Classes/Html/HtmlParser.php b/typo3/sysext/core/Classes/Html/HtmlParser.php index ed1f3fecb3ccfcf6ae903ef52be7c0b00b759ab2..61be53dd7cf4f96346a009c7cb926e7d14ddd99b 100644 --- a/typo3/sysext/core/Classes/Html/HtmlParser.php +++ b/typo3/sysext/core/Classes/Html/HtmlParser.php @@ -454,7 +454,7 @@ class HtmlParser $endTag = $firstChar === '/' ? 1 : 0; $tagContent = substr($tok, $endTag, $tagEnd - $endTag); $tagParts = preg_split('/\\s+/s', $tagContent, 2); - $tagName = strtolower($tagParts[0]); + $tagName = strtolower(rtrim($tagParts[0], '/')); $emptyTag = 0; if (isset($tags[$tagName])) { // If there is processing to do for the tag: diff --git a/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php b/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php index 9f99539a51bc19227f4ca1ed6748c6972f5d1423..65bc60c57bf0b96c9e9ee2ef41a2eb0293e94b2e 100644 --- a/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php +++ b/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php @@ -152,6 +152,28 @@ class HtmlParserTest extends UnitTestCase self::assertSame($expected, $result); } + /** + * @test + * @dataProvider htmlWithDifferentSingleTagsDataProvider + */ + public function htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged(string $exampleString): void + { + $result = $this->subject->HTMLcleaner($exampleString, ['br' => true], 0); + self::assertSame($exampleString, $result); + } + + /** + * Data provider for htmlCleanerCanHandleSingleTagsWithEndingSlashes + */ + public static function htmlWithDifferentSingleTagsDataProvider(): array + { + return [ + 'no slash' => ['one<br>two'], + 'slash without space' => ['one<br/>two'], + 'space and slash' => ['one<br />two'], + ]; + } + /** * Data provider for spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured */