diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index ea36b25e3ce..b33741cd571 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -284,7 +284,6 @@ if (empty($reshook))
} else {
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
}
-
$i++;
}
$sql .= ", 1)";
@@ -341,6 +340,7 @@ if (empty($reshook))
$i++;
}
+
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
//print $sql;exit;
dol_syslog("actionmodify", LOG_DEBUG);
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 2604253d01b..248beb0959d 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5486,23 +5486,24 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
if ($removelinefeed == 2) $stringtoclean = preg_replace('/
]*>(\n|\r)+/ims', '
', $stringtoclean);
$temp = preg_replace('/
]*>/i', "\n", $stringtoclean);
+ // We remove entities BEFORE stripping (in case of a separator char is encoded and not the other, the strip will fails)
+ $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto);
+
if ($strip_tags) {
$temp = strip_tags($temp);
} else {
$pattern = "/<[^<>]+>/";
- // Exemple of $temp: 0000-021
+ // Example of $temp: 0000-021
$temp = preg_replace($pattern, "", $temp); // pass 1
// $temp after pass 1: 0000-021
$temp = preg_replace($pattern, "", $temp); // pass 2
// $temp after pass 2: 0000-021
}
- $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto);
-
- // Supprime aussi les retours
+ // Remove also CR LF
if ($removelinefeed == 1) $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
- // et les espaces doubles
+ // and double spaces
while (strpos($temp, " "))
{
$temp = str_replace(" ", " ", $temp);
diff --git a/htdocs/document.php b/htdocs/document.php
index d4d2b5fb909..ab3ad20a8f8 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -158,7 +158,8 @@ if (GETPOST('type', 'alpha')) $type = GETPOST('type', 'alpha');
else $type = dol_mimetype($original_file);
// Security: Force to octet-stream if file is a dangerous file. For example when it is a .noexe file
// We do not force if file is a javascript to be able to get js from website module with