* Fix #27987 refuse to save signature when too-many-links sanitizer fires When the user signature contains more inline links/images than MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT allows, GETPOST('signature', 'restricthtml') returns the literal string 'ErrorTooManyLinksIntoHTMLString' instead of the sanitized HTML (see dol_string_unicode in htdocs/core/lib/functions.lib.php:8755-8757). On the user/card.php save sites, that literal was assigned verbatim to $object->signature and persisted; the next outgoing email then used the literal as the signature block, so the customer received an email whose entire signature was the string 'ErrorTooManyLinksIntoHTMLString'. Detect the literal at both save sites (action == 'add' around line 316 and action == 'update' around line 499), increment $error, surface a clear setEventMessages and route the user back to the form so the signature is not persisted. The MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT setting is the legitimate guard; this PR only ensures its rejection output never reaches the database or downstream emails. Signed-off-by: Dolicraft <contact@dolicraft.com> * Add ErrorTooManyLinksIntoHTMLString en_US translation pre-commit CI on PR #38534 (Fix #27987) flagged the new lang key ErrorTooManyLinksIntoHTMLString used in user/card.php as missing. Add the en_US entry so the existing helper text from the constant MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT is reachable through $langs->trans(). Signed-off-by: Dolicraft <contact@dolicraft.com> --------- Signed-off-by: Dolicraft <contact@dolicraft.com> Co-authored-by: Dolicraft <contact@dolicraft.com>
This commit is contained in:
parent
b7c5d2c76b
commit
b87ed03b2b
2 changed files with 21 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue