2
0
forked from Wavyzz/dolibarr

Sec: param onlysimplestring is always 1 or 2

This commit is contained in:
Laurent Destailleur
2023-09-08 02:29:20 +02:00
parent 684c0b88b5
commit c2f8c4f47c
4 changed files with 8 additions and 4 deletions

View File

@@ -103,7 +103,7 @@ class box_scheduled_jobs extends ModeleBoxes
while ($i < $num) { while ($i < $num) {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
if (dol_eval($objp->test, 1, 1, '')) { if (dol_eval($objp->test, 1, 1, '2')) {
$nextrun = $this->db->jdate($objp->datenextrun); $nextrun = $this->db->jdate($objp->datenextrun);
if (empty($nextrun)) { if (empty($nextrun)) {
$nextrun = $this->db->jdate($objp->datestart); $nextrun = $this->db->jdate($objp->datestart);

View File

@@ -9175,7 +9175,7 @@ function verifCond($strToEvaluate)
* @param string $s String to evaluate * @param string $s String to evaluate
* @param int $returnvalue 0=No return (used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)). * @param int $returnvalue 0=No return (used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)).
* @param int $hideerrors 1=Hide errors * @param int $hideerrors 1=Hide errors
* @param string $onlysimplestring '0' (used for computed property of extrafields)=Accept all chars, '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';', '2' (rarely used)=Accept also '[]' * @param string $onlysimplestring '0' (deprecated, used for computed property of extrafields)=Accept all chars, '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';', '2' (rarely used)=Accept also '[]'
* @return mixed Nothing or return result of eval * @return mixed Nothing or return result of eval
*/ */
function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1') function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1')
@@ -9192,6 +9192,10 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object
global $soc; // For backward compatibility global $soc; // For backward compatibility
if (!in_array($onlysimplestring, array('0', '1', '2'))) {
return 'Bad call of dol_eval. Parameter onlysimplestring must be 0, 1 or 2';
}
try { try {
// Test on dangerous char (used for RCE), we allow only characters to make PHP variable testing // Test on dangerous char (used for RCE), we allow only characters to make PHP variable testing
if ($onlysimplestring == '1') { if ($onlysimplestring == '1') {

View File

@@ -35,7 +35,7 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield
// If field is a computed field, we make computation to get value // If field is a computed field, we make computation to get value
if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) { if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) {
$objectoffield = $object; //For compatibily with the computed formula $objectoffield = $object; //For compatibily with the computed formula
$value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '0'); $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '2');
if (is_numeric(price2num($value)) && $extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) { if (is_numeric(price2num($value)) && $extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) {
$obj->$tmpkey = price2num($value); $obj->$tmpkey = price2num($value);
} }

View File

@@ -266,7 +266,7 @@ if ($action == "view_ticketlist") {
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') { if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') {
$enabled = abs(dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1, 1, 0)); $enabled = abs(dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1, 1, '2'));
$enabled = (($enabled == 0 || $enabled == 3) ? 0 : $enabled); $enabled = (($enabled == 0 || $enabled == 3) ? 0 : $enabled);
$arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => ($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1, 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $enabled && $extrafields->attributes[$object->table_element]['perms'][$key]); $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => ($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1, 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $enabled && $extrafields->attributes[$object->table_element]['perms'][$key]);
} }