fix ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal to 0

Also replace HTML entities, as we're converting to text
This commit is contained in:
ralf 2022-06-21 14:15:00 +02:00
parent 5cd417ec72
commit 1894a19a86

View File

@ -284,11 +284,12 @@ class Html
// replace fieldset with legend used for original message header
$_html = preg_replace_callback('#<fieldset[^>]*>\s*<legend>(.*?)</legend>\s*(.*?)\s*</fieldset>#sm',
static function($matches)
static function($matches) use ($displayCharset)
{
$len_legend = strlen($legend = $matches[1]);
$len_legend = strlen($legend = html_entity_decode($matches[1], ENT_QUOTES|ENT_SUBSTITUTE, $displayCharset));
$content = preg_replace('/<([^@> ]+@[^> ]+)>/', '#lower#than#$1#greater#than#', $matches[2]);
return "<br>".str_repeat('-', (64-$len_legend-2)>>1).' '.$legend.' '.str_repeat('-', (64-$len_legend-2+1)>>1)."<br>".
return "<br>".str_repeat('-', min(0, (64-$len_legend-2)>>1)).' '.$legend.' '.
str_repeat('-', min(0, (64-$len_legend-2+1)>>1))."<br>".
$content."<br>".str_repeat('-', 64)."<br>";
}, $_html);