Merge pull request #14908 from randompenguin1/develop

Strip HTML tags from content sent as Markdown
This commit is contained in:
Philipp 2025-05-29 19:27:51 +02:00 committed by GitHub
commit 167ac1ec0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -689,7 +689,7 @@ class HTML
public static function toMarkdown(string $html): string
{
DI::profiler()->startRecording('rendering');
$converter = new HtmlConverter(['hard_break' => true]);
$converter = new HtmlConverter(['hard_break' => true, 'strip_tags' => true]);
$markdown = $converter->convert($html);
DI::profiler()->stopRecording();

View file

@ -314,6 +314,11 @@ Karl Marx - Die ursprüngliche Akkumulation
'expected' => '[![abcfgh](https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png "abcfgh")](https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581)',
'text' => '[url=https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581][img=https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png]abcfgh[/img][/url]',
],
/** @see https://github.com/friendica/friendica/pull/14908 */
'task-14908-strip-tags' => [
'expected' => 'Norddeutscher Bürger !\[Noddeutscher Bürger - Bismark Brötchen (Roger Cziwerny - pixapay)\](/rscamo/……)',
'text' => '[class=postbox-ocean]Norddeutscher Bürger ![Noddeutscher Bürger - Bismark Brötchen (Roger Cziwerny - pixapay)](/rscamo/……)[/class]',
],
];
}