diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 1fb0054b05c..f232ecc7d97 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -1718,8 +1718,8 @@ class ActionComm extends CommonObject
$tooltip .= '
';
//$tooltip .= '
'.img_picto('', 'email').' '.$langs->trans("Email").'';
$tooltip .= '
'.$langs->trans('MailTopic').': '.dol_escape_htmltag($this->email_subject);
- $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('<', '>'), $this->email_from);
- $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('<', '>'), $this->email_to);
+ $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('<', '>'), !empty($this->email_from) ? $this->email_from : '');
+ $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('<', '>'), !empty($this->email_to) ? $this->email_to : '');
if (!empty($this->email_tocc)) {
$tooltip .= '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('<', '>'), $this->email_tocc);
}
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index b60e26d2931..e7e10e0cbb6 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -1986,7 +1986,7 @@ class FormFile
} elseif ($sortfield == "date") {
$sortfield = "datea";
} else {
- $sortfield = null;
+ $sortfield = '';
}
$res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder);
$param .= (isset($object->id) ? '&id='.$object->id : '');
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 53af7e7e0c1..72312d1d9ce 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -432,7 +432,9 @@ class FormMail extends Form
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) {
foreach ($this->param['fileinit'] as $file) {
- $this->add_attached_files($file, basename($file), dol_mimetype($file));
+ if (!empty($file)) {
+ $this->add_attached_files($file, basename($file), dol_mimetype($file));
+ }
}
}
}
@@ -1090,7 +1092,7 @@ class FormMail extends Form
$tmparray = $this->withto;
foreach ($tmparray as $key => $val) {
$tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]);
- $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
+ $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true);
}
$withtoselected = GETPOST("receiver", 'array'); // Array of selected value
@@ -1128,7 +1130,7 @@ class FormMail extends Form
$tmparray = $this->withtocc;
foreach ($tmparray as $key => $val) {
$tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]);
- $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
+ $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true);
}
$withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value
$out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, "");
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 6a29b0e7afe..cdd3fdc61ff 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -2006,7 +2006,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
$labeltype = 'AC_OTH';
}
- if (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
+ if (!empty($actionstatic->code) && preg_match('/^TICKET_MSG/', $actionstatic->code)) {
$labeltype = $langs->trans("Message");
} else {
if (!empty($arraylist[$labeltype])) {
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index c3aee82a3bf..d74cae4f054 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -7273,9 +7273,13 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8')
$firstline = preg_replace('/
]*>.*$/s', '', $text); // The s pattern modifier means the . can match newline characters
$firstline = preg_replace('/