From 490d79f774ad51d52d6ba8e18a6b0ef9d2c0d472 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 20 Dec 2018 16:57:46 +0100 Subject: [PATCH] Do not touch email addresses when creating a plaintext message --- api/src/Mail/Html.php | 5 +++-- mail/inc/class.mail_compose.inc.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/Mail/Html.php b/api/src/Mail/Html.php index 8103ed4eb6..cf3fe17c98 100644 --- a/api/src/Mail/Html.php +++ b/api/src/Mail/Html.php @@ -225,9 +225,10 @@ class Html * @param string $displayCharset : charset to use; should be a valid charset * @param bool $stripcrl : flag to indicate for the removal of all crlf \r\n * @param bool $stripalltags : flag to indicate wether or not to strip $_html from all remaining tags + * @param bool $noRepEmailAddr = false, if true email addresses will be intact * @return text $_html : the modified text. */ - static function convertHTMLToText($_html,$displayCharset=false,$stripcrl=false,$stripalltags=true) + static function convertHTMLToText($_html,$displayCharset=false,$stripcrl=false,$stripalltags=true,$noRepEmailAddr = false) { // assume input isHTML, but test the input anyway, because, // if it is not, we may not want to strip whitespace @@ -348,7 +349,7 @@ class Html $_html = preg_replace('~\s*]*>~si',' - ',$_html); $_html = preg_replace('~]+>~s','',$_html); // replace emailaddresses eclosed in <> (eg.: ) with the emailaddress only (e.g: me@you.de) - self::replaceEmailAdresses($_html); + if (!$noRepEmailAddr) self::replaceEmailAdresses($_html); //convert hrefs to description -> URL //$_html = preg_replace('~]+href=\"([^"]+)\"[^>]*>(.*)~si','[$2 -> $1]',$_html); $_html = preg_replace_callback('~]+href=\"([^"]+)\"[^>]*>(.*?)~si','self::transform_url2text',$_html); diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index cc69f45cf3..7855b22304 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2542,7 +2542,7 @@ class mail_compose $_mailObject->setOpenPgpBody($_formData['body']); break; default: - $body = $this->convertHTMLToText($_formData['body'],false); + $body = $this->convertHTMLToText($_formData['body'],false, false, true, true); if ($attachment_links) $body .= $attachment_links;