From ecf73afe869ad54988c8dae1addd503e6b3fc059 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Tue, 5 Aug 2025 01:04:22 +0200 Subject: [PATCH] FIX array for arrayofkeyval is lost in module builder edit of property --- htdocs/core/lib/functions.lib.php | 13 +++++-------- htdocs/modulebuilder/index.php | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9f3469654c6..9b3385e832a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -828,13 +828,12 @@ function GETPOSTISARRAY($paramname, $method = 0) * @param string $check Type of check * '' or 'none'=no check (deprecated) * 'password'=allow characters for a password - * 'email'=allow characters for an email + * 'email'=allow characters for an email "email@domain.com" * 'array', 'array:restricthtml' or 'array:aZ09' to check it's an array * 'int'=check it's numeric (integer or float) * 'intcomma'=check it's integer+comma ('1,2,3,4...') - * 'alpha'=Same than alphanohtml - * 'alphawithlgt'=alpha with lgt - * 'alphanohtml'=check there is no html content and no " and no ../ + * 'alphanohtml'=check there is no html content and no " and no ../ ('alpha' is an alias of 'alphanohtml') + * 'alphawithlgt'=alpha with lgt and no " and no ../ (Can be used for email string like "Name ") * 'aZ'=check it's a-z only * 'aZ09'=check it's simple alpha string (recommended for keys) * 'aZ09arobase'=check it's a string for an element type ('myobject@mymodule') @@ -1190,7 +1189,6 @@ function GETPOSTINT($paramname, $method = 0) return (int) GETPOST($paramname, 'int', $method, null, null, 0); } - /** * Return the value of a $_GET or $_POST supervariable, converted into float. * @@ -1205,7 +1203,6 @@ function GETPOSTFLOAT($paramname, $rounding = '') return (float) price2num(GETPOST($paramname), $rounding, 2); } - /** * Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year, month, day (and * optionally hour, minute, second) fields to return a timestamp. @@ -1353,7 +1350,7 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options } break; case 'alpha': // No html and no ../ and " - case 'alphanohtml': // Recommended for most scalar parameters and search parameters + case 'alphanohtml': // Recommended for most scalar parameters and search parameters. Not valid for json string. if (!is_array($out)) { $out = trim($out); do { @@ -1392,7 +1389,7 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options } while ($oldstringtoclean != $out); } break; - case 'nohtml': // No html + case 'nohtml': // No html. Valid for JSON strings. $out = dol_string_nohtmltag($out, 0); break; case 'restricthtmlnolink': diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 76418dce2df..2b8b6a6c832 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1856,7 +1856,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && 'name' => GETPOST('propname', 'aZ09'), 'label' => GETPOST('proplabel', 'alpha'), 'type' => strtolower(GETPOST('proptype', 'alpha')), - 'arrayofkeyval' => GETPOST('proparrayofkeyval', 'alphawithlgt'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' + 'arrayofkeyval' => GETPOST('proparrayofkeyval', 'nohtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' 'visible' => GETPOST('propvisible', 'alphanohtml'), 'enabled' => GETPOST('propenabled', 'alphanohtml'), 'position' => GETPOSTINT('propposition'),