diff --git a/api/src/Html/HtmLawed.php b/api/src/Html/HtmLawed.php
index a66e02d120..0353a4e9f4 100644
--- a/api/src/Html/HtmLawed.php
+++ b/api/src/Html/HtmLawed.php
@@ -137,28 +137,26 @@ class HtmLawed
*/
static function getStyles(&$html)
{
- $ct=0;
- $newStyle = null;
- if (stripos($html,'#isU', $html, $newStyle);
- if ($ct>0)
+ if (stripos($html,'#isU', $html, $newStyle);
+ if (isset($newStyle))
{
- // this should not be needed, unless something fails with charset detection/ wrong charset passed
- error_log(__METHOD__.__LINE__.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Carset Detected:'.Api\Translation::detect_encoding($style2buffer));
- $style2buffer = utf8_encode($style2buffer);
+ $style2buffer = implode("\n", $newStyle[0]);
+ // only replace what we have found, we use it here, as we use the same routine in Api\Mail\Html::replaceTagsCompletley
+ // no need to do the extra routine
+ $html = str_ireplace($newStyle[0],'',$html);
+ }
+ if (!empty($style2buffer))
+ {
+ $test = json_encode($style2buffer);
+ if ($test=="null" && strlen($style2buffer))
+ {
+ // this should not be needed, unless something fails with charset detection/ wrong charset passed
+ error_log(__METHOD__.__LINE__.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Carset Detected:'.Api\Translation::detect_encoding($style2buffer));
+ $style2buffer = utf8_encode($style2buffer);
+ }
}
}
$style = $style2buffer ?? '';
diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php
index 275ba394b9..d52b285328 100644
--- a/mail/inc/class.mail_ui.inc.php
+++ b/mail/inc/class.mail_ui.inc.php
@@ -3584,6 +3584,11 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
{
$alreadyHtmlLawed=false;
$newBody = $singleBodyPart['body'];
+
+ // remove script tags incl. their content, includes e.g.