diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 4d24adbcce8..5d689374550 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -443,3 +443,4 @@ ThisIdNotDefined=Id not defined OperNotDefined=Payment method not defined EmptyMessageNotAllowedError=Empty message is not allowed SomeShipmentExists=Error, there is some shipment linked to the order. Deletion refused. +ErrorTooManyLinksIntoHTMLString=The HTML content contains too many links or images. Reduce the number or raise MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT. diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 2bffd4d9c7c..0cd12acb160 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -314,6 +314,16 @@ if (empty($reshook)) { $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml')); $object->job = GETPOST("job", 'alphanohtml'); $object->signature = GETPOST("signature", 'restricthtml'); + // restricthtml may swap the value with the literal 'ErrorTooManyLinksIntoHTMLString' + // when the html exceeds MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT (see issue #27987). + // Refuse the save so the literal does not end up persisted and later sent as an + // email body to customers. + if ($object->signature === 'ErrorTooManyLinksIntoHTMLString') { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans('ErrorTooManyLinksIntoHTMLString'), null, 'errors'); + $action = 'create'; + } $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml'); $object->note_public = GETPOST("note_public", 'restricthtml'); $object->note_private = GETPOST("note_private", 'restricthtml'); @@ -497,6 +507,16 @@ if (empty($reshook)) { $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml')); $object->job = GETPOST("job", 'alphanohtml'); $object->signature = GETPOST("signature", 'restricthtml'); + // restricthtml may swap the value with the literal 'ErrorTooManyLinksIntoHTMLString' + // when the html exceeds MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT (see issue #27987). + // Refuse the save so the literal does not end up persisted and later sent as an + // email body to customers. + if ($object->signature === 'ErrorTooManyLinksIntoHTMLString') { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans('ErrorTooManyLinksIntoHTMLString'), null, 'errors'); + $action = 'edit'; + } $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml'); $object->openid = GETPOST("openid", 'alphanohtml'); $object->fk_user = GETPOSTINT("fk_user") > 0 ? GETPOSTINT("fk_user") : 0;