mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-12 12:31:26 +01:00
Sec: param onlysimplestring is always 1 or 2
This commit is contained in:
@@ -103,7 +103,7 @@ class box_scheduled_jobs extends ModeleBoxes
|
||||
while ($i < $num) {
|
||||
$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);
|
||||
if (empty($nextrun)) {
|
||||
$nextrun = $this->db->jdate($objp->datestart);
|
||||
|
||||
@@ -9175,7 +9175,7 @@ function verifCond($strToEvaluate)
|
||||
* @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 $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
|
||||
*/
|
||||
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 $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 {
|
||||
// Test on dangerous char (used for RCE), we allow only characters to make PHP variable testing
|
||||
if ($onlysimplestring == '1') {
|
||||
|
||||
@@ -35,7 +35,7 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield
|
||||
// If field is a computed field, we make computation to get value
|
||||
if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) {
|
||||
$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]) {
|
||||
$obj->$tmpkey = price2num($value);
|
||||
}
|
||||
|
||||
@@ -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'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
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);
|
||||
$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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user