Use plaintext for names and titles

This commit is contained in:
Michael 2023-07-16 07:26:20 +00:00
parent 8bb33dccd1
commit 08dafd6d70
7 changed files with 15 additions and 13 deletions

View file

@ -142,7 +142,7 @@ class BBCode
break;
case 'title':
$value = self::convertForUriId(0, html_entity_decode($value, ENT_QUOTES, 'UTF-8'), BBCode::EXTERNAL);
$value = self::toPlaintext(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
$value = str_replace(['[', ']'], ['[', ']'], $value);
$data['title'] = $value;
@ -226,7 +226,7 @@ class BBCode
* @param bool $keep_urls Whether to keep URLs in the resulting plaintext
* @return string
*/
public static function toPlaintext(string $text, bool $keep_urls = true): string
public static function toPlaintext(string $text, bool $keep_urls = true, bool $strip_tags = false): string
{
DI::profiler()->startRecording('rendering');
// Remove pictures in advance to avoid unneeded proxy calls
@ -238,6 +238,9 @@ class BBCode
$naked_text = HTML::toPlaintext(self::convert($text, false, BBCode::EXTERNAL, true), 0, !$keep_urls);
if ($strip_tags) {
$naked_text = strip_tags($naked_text);
}
DI::profiler()->stopRecording();
return $naked_text;
}