From d59824cd69a063c749a0e33f07e3442c4d5688a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2017 13:19:15 +0100 Subject: [PATCH] Fix generic GETPOST --- htdocs/core/actions_addupdatedelete.inc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b2ec79af5a7..6318e4d5c54 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -46,7 +46,9 @@ if ($action == 'add' && ! empty($permissiontoadd)) { if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields - $value = GETPOST($key,'alpha'); + // Set value to insert + if (in_array($object->fields[$key]['type'], array('text', 'html'))) $value = GETPOST($key,'none'); + else $value = GETPOST($key,'alpha'); if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field @@ -90,7 +92,9 @@ if ($action == 'update' && ! empty($permissiontoadd)) if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields - $value = GETPOST($key,'alpha'); + // Set value to update + if (in_array($object->fields[$key]['type'], array('text', 'html'))) $value = GETPOST($key,'none'); + else $value = GETPOST($key,'alpha'); if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field