diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 235b76aa885..b08d8e55686 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -6638,7 +6638,8 @@ function dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto = 'UTF-8')
*/
function dol_htmlcleanlastbr($stringtodecode)
{
- $ret = preg_replace('/(
|
|'."\n".'|'."\r".')+$/i', "", $stringtodecode);
+ $ret = preg_replace('/ $/i', "", $stringtodecode); // Because wysiwyg editor may add a at end of last line
+ $ret = preg_replace('/(
|
|'."\n".'|'."\r".')+$/i', "", $ret);
return $ret;
}