Normalize escaped Hermes rich text

This commit is contained in:
gitea_admin committed 2026-09-21 15:45:53 +02:00
1 parent 276a496ae8
commit dd019afff6
1 file changed
+9
+9
View File
@@ -64,6 +64,15 @@ function market_management_sanitize_multiline_html(?string $value): ?string
return $value;
}
for ($decodePass = 0; $decodePass < 3; $decodePass++) {
$decoded = html_entity_decode($value, ENT_QUOTES | ENT_HTML5, 'UTF-8');
if ($decoded === $value) {
break;
}
$value = $decoded;
}
$value = preg_replace('/(<a\b[^>]*\bhref\s*=\s*["\'])@url:/iu', '$1', $value) ?? $value;
$tokens = preg_split('/(<\/?a\b[^>]*>|<br\s*\/?>|<\/?strong\s*>)/iu', $value, -1, PREG_SPLIT_DELIM_CAPTURE);
if ($tokens === false) {
return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');