From c4cb3f6d6bc163862cd3be37496aac2ceea455de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Apr 2026 23:34:21 +0200 Subject: [PATCH] FIX Substitution key of default values was not complete. --- htdocs/core/lib/functions.lib.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7f57029ba2b..be6d6333a5f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1063,7 +1063,7 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto', $saverestore = '') */ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null, $options = null, $noreplace = 0) { - global $mysoc, $user, $conf; + global $langs, $mysoc, $user, $conf; if (empty($paramname)) { // Explicit test for null for phan. return 'BadFirstParameterForGETPOST'; @@ -1253,11 +1253,19 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } } - // Substitution variables for GETPOST (used to get final url with variable parameters or final default value, when using variable parameters __XXX__ in the GET URL) + // Replace substitution variables for GETPOST (used to get final url with variable parameters or final default value, when using variable parameters __XXX__ in the GET URL) // Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOMPANY_COUNTRY_ID__, __USER_ID__, ... // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text. '@phan-var-force string $paramname'; if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) { + if (preg_match('/__([A-Z0-9]+(?:_[A-Z0-9]+){0,3})__/i', $out)) { // If there is at least one substitution key, we try to replace all known substitution keys + $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $user, array('mycompany', 'date', 'system', 'user')); + complete_substitutions_array($substitutionarray, $langs, $user); + + $out = make_substitutions($out, $substitutionarray, $langs); + } + + /* old code $reg = array(); $regreplace = array(); $maxloop = 20; @@ -1320,6 +1328,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null $out = preg_replace('/REGREPLACE_' . $key . '/', $value, $out); } } + */ } // Check type of variable and make sanitization according to this