From 5c0813e865ec22e6a15694fe8b96a36dc709ad15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Jun 2014 01:26:41 +0200 Subject: [PATCH] Fix: EMail test feature to make a test without html must not include any html. --- htdocs/admin/mails.php | 12 ++++++++++-- htdocs/core/class/html.formmail.class.php | 11 +++++++---- htdocs/core/lib/functions.lib.php | 4 ++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 16164a14764..78ce79c4912 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -33,20 +33,28 @@ $langs->load("mails"); $langs->load("other"); $langs->load("errors"); +$action=GETPOST('action','alpha'); + if (! $user->admin) accessforbidden(); +$usersignature=$user->signature; +// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. +if ($action == 'test' || $action == 'send') +{ + $usersignature=dol_string_nohtmltag($usersignature); +} + $substitutionarrayfortest=array( '__LOGIN__' => $user->login, '__ID__' => 'TESTIdRecord', '__EMAIL__' => 'TESTEMail', '__LASTNAME__' => 'TESTLastname', '__FIRSTNAME__' => 'TESTFirstname', -'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''), +'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), //'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet ); complete_substitutions_array($substitutionarrayfortest, $langs); -$action=GETPOST('action'); /* diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b9f5e7e1bc1..9d80ced54e3 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -102,7 +102,7 @@ class FormMail $this->withfilereadonly=0; $this->withbodyreadonly=0; $this->withdeliveryreceiptreadonly=0; - $this->withfckeditor=0; + $this->withfckeditor=-1; // -1 = Auto return 1; } @@ -222,7 +222,7 @@ class FormMail global $conf, $langs, $user, $hookmanager, $form; if (! is_object($form)) $form=new Form($this->db); - + $langs->load("other"); $langs->load("mails"); @@ -619,9 +619,12 @@ class FormMail // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { - $this->withfckeditor=1; + if ($this->withfckeditor == -1) + { + if (! empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor=1; + else $this->withfckeditor=0; } + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); $out.= $doleditor->Create(1); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bc38958fa9e..e81c8b3b2d9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -457,6 +457,8 @@ function dol_escape_js($stringtoescape, $mode=0) * @param string $stringtoescape String to escape * @param int $keepb Do not clean b tags * @return string Escaped string + * + * @see dol_string_nohtmltag */ function dol_escape_htmltag($stringtoescape,$keepb=0) { @@ -3436,6 +3438,8 @@ function picto_required() * @param string $removelinefeed Replace also all lines feeds by a space, otherwise only last one are removed * @param string $pagecodeto Encoding of input/output string * @return string String cleaned + * + * @see dol_escape_htmltag */ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') {