diff --git a/api/src/Mail/Html.php b/api/src/Mail/Html.php index b8b55e08cf..6cf890e3d8 100644 --- a/api/src/Mail/Html.php +++ b/api/src/Mail/Html.php @@ -273,7 +273,7 @@ class Html chr(161), chr(162), chr(163), - '(C)',//chr(169),// copyrighgt + '(C)',//chr(169),// copyright '(R)',//chr(174),// registered '(TM)',// trade "'", @@ -282,6 +282,16 @@ class Html ); $_html = preg_replace($Rules, $Replace, $_html); + // replace fieldset with legend used for original message header + $_html = preg_replace_callback('#]*>\s*(.*)\s*(.*)\s*#sm', + static function($matches) + { + $len_legend = strlen($legend = $matches[1]); + $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)."
". + $content.str_repeat('-', 64)."
"; + }, $_html); + // removing carriage return linefeeds, preserve those enclosed in
 
tags if ($stripcrl === true ) { @@ -584,4 +594,4 @@ class Html //error_log(__METHOD__.__LINE__.array2string($html2ret)); return $html2ret; } -} +} \ No newline at end of file diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 7083cddb68..ffa762676e 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2261,7 +2261,7 @@ class mail_compose //_debug_array($bodyParts); $styles = Mail::getStyles($bodyParts); - $fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM'])); + $fromAddress = implode(', ', $headers['FROM']); $toAddressA = array(); $toAddress = ''; @@ -2270,8 +2270,8 @@ class mail_compose } if (count($toAddressA)>0) { - $toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA)); - $toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"
":"\r\n"); + $toAddress = implode(', ', $toAddressA); + $toAddress = htmlspecialchars(lang("to").": ".$toAddress).($bodyParts['0']['mimeType'] == 'text/html'?"
":"\r\n"); } $ccAddressA = array(); $ccAddress = ''; @@ -2280,15 +2280,18 @@ class mail_compose } if (count($ccAddressA)>0) { - $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); - $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"
":"\r\n"); + $ccAddress = implode(', ', $ccAddressA); + $ccAddress = htmlspecialchars(lang("cc").": ".$ccAddress).($bodyParts['0']['mimeType'] == 'text/html'?"
":"\r\n"); } - if($bodyParts['0']['mimeType'] == 'text/html') { - $this->sessionData['body'] = "
"."
".'----------------'.lang("original message").'-----------------'."".'
'. - @htmlspecialchars(lang("from")).": ".$fromAddress."
". - $toAddress.$ccAddress. - @htmlspecialchars(lang("date").": ".Mail::_strtotime($headers['DATE'],'r',true),ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."
". - '----------------------------------------------------------'."
"; + // create original message header in users preferred font and -size + $this->sessionData['body'] = self::wrapBlockWithPreferredFont( + htmlspecialchars(lang("from").": ".$fromAddress)."
". + $toAddress.$ccAddress. + htmlspecialchars(lang("date").": ".Mail::_strtotime($headers['DATE'],'r',true),ENT_QUOTES | ENT_IGNORE, Mail::$displayCharset, false), + lang("original message"), 'originalMessage'); + + if($bodyParts['0']['mimeType'] == 'text/html') + { $this->sessionData['mimeType'] = 'html'; if (!empty($styles)) $this->sessionData['body'] .= $styles; $this->sessionData['body'] .= '
'; @@ -2314,14 +2317,12 @@ class mail_compose $this->sessionData['body'] .= '

'; $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); - } else { - //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; - // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) - $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". - @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". - $toAddress.$ccAddress. - @htmlspecialchars(lang("date").": ".Mail::_strtotime($headers['DATE'],'r',true), ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n". - '-------------------------------------------------'."\r\n \r\n "; + } + else + { + // convert original message header to plain-text + $this->sessionData['body'] = self::convertHTMLToText($this->sessionData['body'], true, false, true); + $this->sessionData['mimeType'] = 'plain'; foreach($bodyParts as $i => &$bodyPart) { @@ -2368,11 +2369,30 @@ class mail_compose } + /** + * Wrap html block in given tag with preferred font and -size set + * + * @param string $content + * @param string $legend + * @param ?string $class + * @return string + */ + static function wrapBlockWithPreferredFont($content, $legend, $class=null) + { + $options = ' style="border: 2px solid silver; border-left: none; border-right: none;'. + 'font-family: '.($GLOBALS['egw_info']['user']['preferences']['common']['rtf_font'] ?? 'arial, helvetica, sans-serif'). + '; font-size: '.($GLOBALS['egw_info']['user']['preferences']['common']['rtf_size'] ?? '10').'pt"'; + + if (!empty($class)) $options .= ' class="'.htmlspecialchars($class).'"'; + + return Api\Html::fieldset($content, $legend, $options); + } + /** * HTML cleanup * * @param type $_body message - * @param type $_useTidy = false, if true tidy extention will be loaded and tidy will try to clean body message + * @param type $_useTidy = false, if true tidy extension will be loaded and tidy will try to clean body message * since the tidy causes segmentation fault ATM, we set the default to false. * @return type */