From 1894a19a86dbbd647fd8d252ea4207f6df03c321 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 21 Jun 2022 14:15:00 +0200 Subject: [PATCH] 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 --- api/src/Mail/Html.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/Mail/Html.php b/api/src/Mail/Html.php index c720ad9909..491c4b4379 100644 --- a/api/src/Mail/Html.php +++ b/api/src/Mail/Html.php @@ -284,11 +284,12 @@ class Html // replace fieldset with legend used for original message header $_html = preg_replace_callback('#]*>\s*(.*?)\s*(.*?)\s*#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 "
".str_repeat('-', (64-$len_legend-2)>>1).' '.$legend.' '.str_repeat('-', (64-$len_legend-2+1)>>1)."
". + return "
".str_repeat('-', min(0, (64-$len_legend-2)>>1)).' '.$legend.' '. + str_repeat('-', min(0, (64-$len_legend-2+1)>>1))."
". $content."
".str_repeat('-', 64)."
"; }, $_html);