CVE-2022-0819: Other (NVD-CWE-Other)
value: Code Injection in GitHub repository dolibarr/dolibarr prior to 15.0.1.
CWE description: NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
CVSS v3 base score: 8.8
Published: 2022-03-02T16:15Z
Repository: https://github.com/dolibarr/dolibarr
Language: PHP
Files changed: htdocs/admin/emailcollector_list.php, htdocs/admin/mails_templates.php, htdocs/admin/menus/edit.php, htdocs/bom/bom_list.php, htdocs/compta/cashcontrol/cashcontrol_list.php, htdocs/compta/facture/list.php, htdocs/compta/resultat/result.php, htdocs/core/boxes/box_scheduled_jobs.php, htdocs/core/class/commonobject.class.php, htdocs/core/class/extrafields.class.php, htdocs/core/class/html.form.class.php, htdocs/core/class/html.formother.class.php, htdocs/core/class/menu.class.php, htdocs/core/class/translate.class.php, htdocs/core/customreports.php, htdocs/core/lib/functions.lib.php, htdocs/core/tpl/admin_extrafields_view.tpl.php, htdocs/core/tpl/extrafields_list_array_fields.tpl.php, htdocs/core/tpl/extrafields_list_print_fields.tpl.php, htdocs/eventorganization/conferenceorbooth_list.php, htdocs/eventorganization/conferenceorboothattendee_list.php, htdocs/hrm/evaluation_list.php, htdocs/hrm/job_list.php, htdocs/hrm/position.php, htdocs/hrm/position_list.php, htdocs/hrm/skill_card.php, htdocs/hrm/skill_list.php, htdocs/knowledgemanagement/knowledgerecord_list.php, htdocs/mrp/mo_list.php, htdocs/partnership/partnership_list.php, htdocs/product/inventory/list.php, htdocs/product/list.php, htdocs/product/stock/list.php, htdocs/product/stock/productlot_list.php, htdocs/projet/class/task.class.php, htdocs/projet/list.php, htdocs/recruitment/recruitmentcandidature_list.php, htdocs/recruitment/recruitmentjobposition_list.php, htdocs/salaries/list.php, htdocs/salaries/payments.php, htdocs/ticket/list.php, htdocs/workstation/workstation_list.php, test/phpunit/SecurityTest.php
Commit date: 2022-03-01 16:38:06 +0100
Commit message: Fix #hunterb03d4415-d4f9-48c8-9ae2-d3aa248027b5
Diff: diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php
index af137a1ecdb7..9e93dd78b863 100644
--- a/htdocs/admin/emailcollector_list.php
+++ b/htdocs/admin/emailcollector_list.php
@@ -107,15 +107,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = dol_eval($val['visible'], 1);
+		$visible = dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position']
 		);
 	}
 }
 // Extra fields
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index fb3a1ccf702e..803f3b745369 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -1032,11 +1032,11 @@ if ($resql) {
 				if (!in_array($obj->$keyforobj, array_keys($elementList))) {
 					$i++;
 					continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled)
 				}
 				// Test on 'enabled'
-				if (!dol_eval($obj->enabled, 1)) {
+				if (!dol_eval($obj->enabled, 1, 1, '1')) {
 					$i++;
 					continue; // Email template not qualified
 				}
 
 				print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index 02c46d8ca35e..a9e2fe9287fc 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -462,11 +462,11 @@ if ($action == 'create') {
 	if ($menu->fk_leftmenu) {
 		$valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu;
 	}
 	print '<td><input type="text" name="menuIdParent" value="'.$valtouse.'" class="minwidth300"></td>';
 	print '<td>'.$langs->trans('DetailMenuIdParent');
-	print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
+	print ', <span class="opacitymedium">'.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def</span>';
 	print '</td></tr>';
 
 	// Niveau
 	//print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
 
@@ -494,19 +494,19 @@ if ($action == 'create') {
 
 	// Enabled
 	print '<tr><td>'.$langs->trans('Enabled').'</td>';
 	print '<td><input type="text" class="minwidth500" name="enabled" value="'.dol_escape_htmltag($menu->enabled).'"></td><td>'.$langs->trans('DetailEnabled');
 	if (!empty($menu->enabled)) {
-		print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
+		print ' <span class="opacitymedium">('.$langs->trans("ConditionIsCurrently").':</span> '.yn(dol_eval($menu->enabled, 1, 1, '1')).')';
 	}
 	print '</td></tr>';
 
 	// Perms
 	print '<tr><td>'.$langs->trans('Rights').'</td>';
 	print '<td><input type="text" class="minwidth500" name="perms" value="'.dol_escape_htmltag($menu->perms).'"></td><td>'.$langs->trans('DetailRight');
 	if (!empty($menu->perms)) {
-		print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
+		print ' <span class="opacitymedium">('.$langs->trans("ConditionIsCurrently").':</span> '.yn(dol_eval($menu->perms, 1, 1, '1')).')';
 	}
 	print '</td></tr>';
 
 	print '</table>';
 
diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php
index 3cc0dc1753a7..48798db9b8f9 100644
--- a/htdocs/bom/bom_list.php
+++ b/htdocs/bom/bom_list.php
@@ -104,11 +104,11 @@ foreach ($object->fields as $key => $val) {
 	if (!empty($val['visible'])) {
 		$visible = (int) dol_eval($val['visible'], 1);
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php
index 89781fcb211e..7822819c06a7 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_list.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_list.php
@@ -102,15 +102,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 0e3acc45d250..353181749992 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -259,18 +259,18 @@ if (getDolGlobalString("INVOICE_USE_SITUATION") && $conf->global->INVOICE_USE_RE
 }
 // Overwrite $arrayfields from columns into ->fields (transition before removal of $arrayoffields)
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$newkey = '';
 		if (array_key_exists($key, $arrayfields)) { $newkey = $key; } elseif (array_key_exists('t.'.$key, $arrayfields)) { $newkey = 't.'.$key; } elseif (array_key_exists('f.'.$key, $arrayfields)) { $newkey = 'f.'.$key; } elseif (array_key_exists('s.'.$key, $arrayfields)) { $newkey = 's.'.$key; }
 		if ($newkey) {
 			$arrayfields[$newkey] = array(
 				'label'=>$val['label'],
 				'checked'=>(($visible < 0) ? 0 : 1),
-				'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+				'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 				'position'=>$val['position'],
 				'help' => empty($val['help']) ? '' : $val['help'],
 			);
 		}
 	}
diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php
index 635531ab86b8..c296d4037e59 100644
--- a/htdocs/compta/resultat/result.php
+++ b/htdocs/compta/resultat/result.php
@@ -332,11 +332,11 @@ if ($modecompta == 'CREANCES-DETTES') {
 
 				$result = strtr($formula, $vars);
 
 				//var_dump($result);
 				//$r = $AccCat->calculate($result);
-				$r = dol_eval($result, 1);
+				$r = dol_eval($result, 1, 1, '1');
 				//var_dump($r);
 
 				print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
 
 				// Year N
@@ -351,11 +351,11 @@ if ($modecompta == 'CREANCES-DETTES') {
 				}
 
 				$result = strtr($formula, $vars);
 
 				//$r = $AccCat->calculate($result);
-				$r = dol_eval($result, 1);
+				$r = dol_eval($result, 1, 1, 1);
 
 				print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
 				$sommes[$code]['N'] += $r;
 
 				// Detail by month
@@ -365,11 +365,11 @@ if ($modecompta == 'CREANCES-DETTES') {
 							$vars[$code] = $det['M'][$k];
 						}
 						$result = strtr($formula, $vars);
 
 						//$r = $AccCat->calculate($result);
-						$r = dol_eval($result, 1);
+						$r = dol_eval($result, 1, 1, 1);
 
 						print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
 						$sommes[$code]['M'][$k] += $r;
 					}
 				}
@@ -379,11 +379,11 @@ if ($modecompta == 'CREANCES-DETTES') {
 							$vars[$code] = $det['M'][$k];
 						}
 						$result = strtr($formula, $vars);
 
 						//$r = $AccCat->calculate($result);
-						$r = dol_eval($result, 1);
+						$r = dol_eval($result, 1, 1, 1);
 
 						print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
 						$sommes[$code]['M'][$k] += $r;
 					}
 				}
diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php
index 94695034ccea..f21956596542 100644
--- a/htdocs/core/boxes/box_scheduled_jobs.php
+++ b/htdocs/core/boxes/box_scheduled_jobs.php
@@ -100,11 +100,11 @@ class box_scheduled_jobs extends ModeleBoxes
 
 				$i = 0;
 				while ($i < $num) {
 					$objp = $this->db->fetch_object($result);
 
-					if (dol_eval($objp->test, 1, 1)) {
+					if (dol_eval($objp->test, 1, 1, '')) {
 						$nextrun = $this->db->jdate($objp->datenextrun);
 						if (empty($nextrun)) {
 							$nextrun = $this->db->jdate($objp->datestart);
 						}
 
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 4b3d6fca2d3f..179f12553066 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -5673,16 +5673,16 @@ abstract class CommonObject
 
 			$key_type = $this->fields[$key]['type'];
 
 			$enabled = 1;
 			if (isset($this->fields[$key]['enabled'])) {
-				$enabled = dol_eval($this->fields[$key]['enabled'], 1);
+				$enabled = dol_eval($this->fields[$key]['enabled'], 1, 1, '1');
 			}
 			/*$perms = 1;
 			if (isset($this->fields[$key]['perms']))
 			{
-				$perms = dol_eval($this->fields[$key]['perms'], 1);
+				$perms = dol_eval($this->fields[$key]['perms'], 1, 1, '1');
 			}*/
 			if (empty($enabled)) {
 				continue;
 			}
 			//if (empty($perms)) continue;
@@ -5834,11 +5834,11 @@ abstract class CommonObject
 					// If field is a computed field, value must become result of compute
 					foreach ($tab as $key => $value) {
 						if (!empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
 							//var_dump($conf->disable_compute);
 							if (empty($conf->disable_compute)) {
-								$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0);
+								$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '');
 							}
 						}
 					}
 				}
 
@@ -5965,11 +5965,11 @@ abstract class CommonObject
 				//dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG);
 				//dol_syslog("attributeType=".$attributeType, LOG_DEBUG);
 
 				if (!empty($attrfieldcomputed)) {
 					if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) {
-						$value = dol_eval($attrfieldcomputed, 1, 0);
+						$value = dol_eval($attrfieldcomputed, 1, 0, '');
 						dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG);
 						$new_array_options[$key] = $value;
 					} else {
 						$new_array_options[$key] = null;
 					}
@@ -6332,11 +6332,11 @@ abstract class CommonObject
 			//dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG);
 			//dol_syslog("attributeType=".$attributeType, LOG_DEBUG);
 
 			if (!empty($attrfieldcomputed)) {
 				if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) {
-					$value = dol_eval($attrfieldcomputed, 1, 0);
+					$value = dol_eval($attrfieldcomputed, 1, 0, '');
 					dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG);
 					$this->array_options["options_".$key] = $value;
 				} else {
 					$this->array_options["options_".$key] = null;
 				}
@@ -7186,11 +7186,11 @@ abstract class CommonObject
 
 		// If field is a computed field, value must become result of compute
 		if ($computed) {
 			// Make the eval of compute string
 			//var_dump($computed);
-			$value = dol_eval($computed, 1, 0);
+			$value = dol_eval($computed, 1, 0, '');
 		}
 
 		if (empty($morecss)) {
 			if ($type == 'date') {
 				$morecss = 'minwidth100imp';
@@ -7711,24 +7711,24 @@ abstract class CommonObject
 					}
 
 					// Test on 'enabled' ('enabled' is different than 'list' = 'visibility')
 					$enabled = 1;
 					if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) {
-						$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1);
+						$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '1');
 					}
 					if (empty($enabled)) {
 						continue;
 					}
 
 					$visibility = 1;
 					if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key])) {
-						$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1);
+						$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '1');
 					}
 
 					$perms = 1;
 					if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) {
-						$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1);
+						$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '1');
 					}
 
 					if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) {
 						continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
 					} elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) {
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 2b827d06f36f..ff45a028d519 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -913,13 +913,13 @@ class ExtraFields
 			$default = $this->attributes[$extrafieldsobjectkey]['default'][$key];
 			$computed = $this->attributes[$extrafieldsobjectkey]['computed'][$key];
 			$unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key];
 			$required = $this->attributes[$extrafieldsobjectkey]['required'][$key];
 			$param = $this->attributes[$extrafieldsobjectkey]['param'][$key];
-			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1);
+			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1');
 			$langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key];
-			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1);
+			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1');
 			$totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key];
 			$help = $this->attributes[$extrafieldsobjectkey]['help'][$key];
 			$hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
 		} else {
 			// Old usage
@@ -1503,13 +1503,13 @@ class ExtraFields
 			$default = $this->attributes[$extrafieldsobjectkey]['default'][$key];
 			$computed = $this->attributes[$extrafieldsobjectkey]['computed'][$key];
 			$unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key];
 			$required = $this->attributes[$extrafieldsobjectkey]['required'][$key];
 			$param = $this->attributes[$extrafieldsobjectkey]['param'][$key];
-			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1);
+			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1');
 			$langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key];
-			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1);
+			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1');
 			$help = $this->attributes[$extrafieldsobjectkey]['help'][$key];
 			$hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
 		} else {
 			// Old usage not allowed anymore
 			dol_syslog(get_class($this).'::showOutputField extrafieldsobjectkey required', LOG_WARNING);
@@ -1957,21 +1957,21 @@ class ExtraFields
 					continue;
 				}
 
 				$enabled = 1;
 				if (isset($this->attributes[$object->table_element]['enabled'][$key])) {	// 'enabled' is often a condition on module enabled or not
-					$enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1);
+					$enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1, 1, '1');
 				}
 
 				$visibility = 1;
 				if (isset($this->attributes[$object->table_element]['list'][$key])) {		// 'list' is option for visibility
-					$visibility = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
+					$visibility = dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '1');
 				}
 
 				$perms = 1;
 				if (isset($this->attributes[$object->table_element]['perms'][$key])) {
-					$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
+					$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1, 1, '1');
 				}
 				if (empty($enabled)) {
 					continue;
 				}
 				if (empty($visibility)) {
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index f25c9aad9d37..975e6ed86ea3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -7422,11 +7422,11 @@ class Form
 		$confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
 
 		if (!empty($objecttmp->fields)) {	// For object that declare it, it is better to use declared fields (like societe, contact, ...)
 			$tmpfieldstoshow = '';
 			foreach ($objecttmp->fields as $key => $val) {
-				if (!dol_eval($val['enabled'], 1, 1)) {
+				if (!dol_eval($val['enabled'], 1, 1, 1, '1')) {
 					continue;
 				}
 				if (!empty($val['showoncombobox'])) {
 					$tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
 				}
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index aa0e54867619..6dae77dffa49 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -1499,14 +1499,14 @@ class FormOther
 				if (in_array($key, array(
 					'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
 					'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
 					continue;
 				}
-				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
+				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1, 1, '1')) {
 					continue;
 				}
-				if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
+				if (isset($val['visible']) && !dol_eval($val['visible'], 1, 1, '1')) {
 					continue;
 				}
 				if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
 					continue;
 				}
@@ -1573,14 +1573,14 @@ class FormOther
 				if (in_array($key, array(
 					'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
 					'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
 					continue;
 				}
-				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
+				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1, 1, '1')) {
 					continue;
 				}
-				if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
+				if (isset($val['visible']) && !dol_eval($val['visible'], 1, 1, '1')) {
 					continue;
 				}
 				if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
 					continue;
 				}
diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php
index e88ec7013200..eab31288cca9 100644
--- a/htdocs/core/class/menu.class.php
+++ b/htdocs/core/class/menu.class.php
@@ -117,11 +117,11 @@ class Menu
 	 */
 	public function getNbOfVisibleMenuEntries()
 	{
 		$nb = 0;
 		foreach ($this->liste as $val) {
-			//if (dol_eval($val['enabled'], 1)) $nb++;
+			//if (dol_eval($val['enabled'], 1, 1, '1')) $nb++;
 			if (!empty($val['enabled'])) {
 				$nb++; // $val['enabled'] is already evaluated to 0 or 1, no need for dol_eval()
 			}
 		}
 		return $nb;
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index f881447cd67f..5bfdbc7e0f18 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -654,11 +654,11 @@ class Translate
 				$str = dol_trunc($str, $maxsize);
 			}
 
 			return $str;
 		} else { // Translation is not available
-			//if ($key[0] == '$') { return dol_eval($key,1); }
+			//if ($key[0] == '$') { return dol_eval($key, 1, 1, '1'); }
 			return $this->getTradFromKey($key);
 		}
 	}
 
 
@@ -720,11 +720,11 @@ class Translate
 			}
 
 			return $str;
 		} else {
 			if ($key[0] == '$') {
-				return dol_eval($key, 1);
+				return dol_eval($key, 1, 1, '1');
 			}
 			return $this->getTradFromKey($key);
 		}
 	}
 
diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php
index fafd1c015e88..0ff8ebc4e647 100644
--- a/htdocs/core/customreports.php
+++ b/htdocs/core/customreports.php
@@ -369,11 +369,11 @@ print '<div class="liste_titre liste_titre_bydiv centpercent">';
 // Select object
 print '<div class="divadvancedsearchfield center floatnone">';
 print '<div class="inline-block"><span class="opacitymedium">'.$langs->trans("StatisticsOn").'</span></div> ';
 $newarrayoftype = array();
 foreach ($arrayoftype as $key => $val) {
-	if (dol_eval($val['enabled'], 1)) {
+	if (dol_eval($val['enabled'], 1, 1, '1')) {
 		$newarrayoftype[$key] = $arrayoftype[$key];
 	}
 	if ($val['langs']) {
 		$langs->load($val['langs']);
 	}
@@ -400,21 +400,21 @@ print $form->searchComponent(array($object->element => $object->fields), $search
 print '</div>';
 
 // Add measures into array
 print '<div class="divadvancedsearchfield clearboth">';
 foreach ($object->fields as $key => $val) {
-	if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) {
+	if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
 		$arrayofmesures['t.'.$key.'-sum'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
 		$arrayofmesures['t.'.$key.'-average'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
 		$arrayofmesures['t.'.$key.'-min'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
 		$arrayofmesures['t.'.$key.'-max'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
 	}
 }
 // Add extrafields to Measures
 if ($object->isextrafieldmanaged) {
 	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
-		if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) {
+		if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
 			$arrayofmesures['te.'.$key.'-sum'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
 			$arrayofmesures['te.'.$key.'-average'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
 			$arrayofmesures['te.'.$key.'-min'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
 			$arrayofmesures['te.'.$key.'-max'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
 		}
@@ -441,11 +441,11 @@ print '</div>';
 
 if ($mode == 'grid') {
 	// YAxis
 	print '<div class="divadvancedsearchfield">';
 	foreach ($object->fields as $key => $val) {
-		if (empty($val['measure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) {
+		if (empty($val['measure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
 			if (in_array($key, array('id', 'rowid', 'entity', 'last_main_doc', 'extraparams'))) {
 				continue;
 			}
 			if (preg_match('/^fk_/', $key)) {
 				continue;
@@ -462,11 +462,11 @@ if ($mode == 'grid') {
 			}
 		}
 		// Add measure from extrafields
 		if ($object->isextrafieldmanaged) {
 			foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
-				if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) {
+				if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
 					$arrayofyaxis['te.'.$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key]);
 				}
 			}
 		}
 	}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 513534ba38c6..c6476f98a116 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -8186,16 +8186,17 @@ function verifCond($strToEvaluate)
 
 /**
  * Replace eval function to add more security.
  * This function is called by verifCond() or trans() and transnoentitiesnoconv().
  *
- * @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
- * @return	mixed					Nothing or return result of eval
+ * @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	Accept only simple string with char 'a-z0-9\s$_->&|=';
+ * @return	mixed						Nothing or return result of eval
  */
-function dol_eval($s, $returnvalue = 0, $hideerrors = 1)
+function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1')
 {
 	// Only global variables can be changed by eval function and returned to caller
 	global $db, $langs, $user, $conf, $website, $websitepage;
 	global $action, $mainmenu, $leftmenu;
 	global $rights;
@@ -8203,21 +8204,30 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1)
 	global $mysoc;
 
 	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
 
-	// Replace dangerous char (used for RCE), we allow only PHP variable testing.
+	// Test dangerous char (used for RCE), we allow only PHP variable testing.
+	if ($onlysimplestring == '1') {
+		//print preg_quote('$_->&|', '/');
+		if (preg_match('/[^a-z0-9\s'.preg_quote('$_->&|=', '/').']/i', $s)) {
+			return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
+		}
+	}
 	if (strpos($s, '`') !== false) {
-		return 'Bad string syntax to evaluate: '.$s;
+		return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
+	}
+	if (strpos($s, '.') !== false) {
+		return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
 	}
 
 	// We block use of php exec or php file functions
 	$forbiddenphpstrings = array('$$');
 	$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST'));
 
 	$forbiddenphpfunctions = array("exec", "passthru", "shell_exec", "system", "proc_open", "popen", "eval", "dol_eval", "executeCLI");
-	$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask"));
+	$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "require", "include", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
 	$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("function", "call_user_func"));
 
 	$forbiddenphpregex = 'global\s+\$|\b('.implode('|', $forbiddenphpfunctions).')\b';
 
 	do {
diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php
index d1145229db7b..369f60ea2018 100644
--- a/htdocs/core/tpl/admin_extrafields_view.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php
@@ -71,11 +71,11 @@ if (!empty($conf->multicompany->enabled)) {
 print '<td width="80">&nbsp;</td>';
 print "</tr>\n";
 
 if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) {
 	foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) {
-		/*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1)) {
+		/*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1, 1, '1')) {
 			// TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled"
 			// continue;
 		}*/
 
 		// Load language if required
diff --git a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
index 36eeee89627b..b704891da16d 100644
--- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
@@ -21,13 +21,13 @@ if (!empty($extrafieldsobjectkey)) {	// $extrafieldsobject is the $object->table
 		foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) {
 			if (!empty($extrafields->attributes[$extrafieldsobjectkey]['list'][$key])) {
 				$arrayfields[$extrafieldsobjectprefix.$key] = array(
 					'label'    => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key],
 					'type'     => $extrafields->attributes[$extrafieldsobjectkey]['type'][$key],
-					'checked'  => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1) <= 0) ? 0 : 1),
+					'checked'  => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1') <= 0) ? 0 : 1),
 					'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key],
-					'enabled'  => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key], 1)),
+					'enabled'  => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1')),
 					'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key],
 					'help'     => $extrafields->attributes[$extrafieldsobjectkey]['help'][$key],
 				);
 			}
 		}
diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
index 80d6cd7da56f..00c2739e3f83 100644
--- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
@@ -36,11 +36,11 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield
 				if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) {
 					//global $obj, $object;
 					//var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]);
 					//var_dump($obj);
 					//var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]);
-					$value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1);
+					$value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '0');
 					//var_dump($value);
 				}
 
 				$valuetoshow = $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey);
 				$title = dol_string_nohtmltag($valuetoshow);
diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php
index d105ad05c43f..943205adca29 100644
--- a/htdocs/eventorganization/conferenceorbooth_list.php
+++ b/htdocs/eventorganization/conferenceorbooth_list.php
@@ -112,15 +112,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php
index e084c68cfe7b..ab2699187b22 100644
--- a/htdocs/eventorganization/conferenceorboothattendee_list.php
+++ b/htdocs/eventorganization/conferenceorboothattendee_list.php
@@ -120,15 +120,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php
index 35189f11b871..ad99573b0962 100644
--- a/htdocs/hrm/evaluation_list.php
+++ b/htdocs/hrm/evaluation_list.php
@@ -112,15 +112,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php
index 55363d729b55..7644ea1fd0fd 100644
--- a/htdocs/hrm/job_list.php
+++ b/htdocs/hrm/job_list.php
@@ -112,15 +112,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php
index d36d352e8956..253945e6c5ac 100644
--- a/htdocs/hrm/position.php
+++ b/htdocs/hrm/position.php
@@ -355,15 +355,15 @@ function DisplayPositionList()
 	// Definition of array of fields for columns
 	$arrayfields = array();
 	foreach ($object->fields as $key => $val) {
 		// If $val['visible']==0, then we never show the field
 		if (!empty($val['visible'])) {
-			$visible = (int) dol_eval($val['visible'], 1);
+			$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 			$arrayfields['t.' . $key] = array(
 				'label' => $val['label'],
 				'checked' => (($visible < 0) ? 0 : 1),
-				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1)),
+				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 				'position' => $val['position'],
 				'help' => isset($val['help']) ? $val['help'] : ''
 			);
 		}
 	}
diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php
index 1585ed1e03fe..13315a2a9bcb 100644
--- a/htdocs/hrm/position_list.php
+++ b/htdocs/hrm/position_list.php
@@ -112,15 +112,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php
index a06cf40952a8..7c63bb2cff75 100644
--- a/htdocs/hrm/skill_card.php
+++ b/htdocs/hrm/skill_card.php
@@ -536,15 +536,15 @@ if ($action != "create" && $action != "edit") {
 	// Definition of array of fields for columns
 	$arrayfields = array();
 	foreach ($objectline->fields as $key => $val) {
 		// If $val['visible']==0, then we never show the field
 		if (!empty($val['visible'])) {
-			$visible = (int) dol_eval($val['visible'], 1);
+			$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 			$arrayfields['t.' . $key] = array(
 				'label' => $val['label'],
 				'checked' => (($visible < 0) ? 0 : 1),
-				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1)),
+				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 				'position' => $val['position'],
 				'help' => isset($val['help']) ? $val['help'] : ''
 			);
 		}
 	}
diff --git a/htdocs/hrm/skill_list.php b/htdocs/hrm/skill_list.php
index 1fc5440e5893..8ef800b3ffc8 100644
--- a/htdocs/hrm/skill_list.php
+++ b/htdocs/hrm/skill_list.php
@@ -112,15 +112,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php
index aed45b1db260..c4440028e494 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_list.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_list.php
@@ -112,15 +112,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php
index e5648cad5f78..6e15a71e517d 100644
--- a/htdocs/mrp/mo_list.php
+++ b/htdocs/mrp/mo_list.php
@@ -107,15 +107,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php
index 89394960632b..dc9958fa3df1 100644
--- a/htdocs/partnership/partnership_list.php
+++ b/htdocs/partnership/partnership_list.php
@@ -116,15 +116,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php
index 41e43fdf433c..c4548b3aa665 100644
--- a/htdocs/product/inventory/list.php
+++ b/htdocs/product/inventory/list.php
@@ -100,15 +100,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index a3ec599dea8a..26dbf18e4390 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -242,15 +242,15 @@ $arrayfields = array(
 	'p.tobuy'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Buy").')', 'checked'=>1, 'position'=>1000)
 );
 /*foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = dol_eval($val['visible'], 1);
+		$visible = dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['p.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position']
 		);
 	}
 }*/
 
diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php
index 8f24fb9c110d..93c963e00655 100644
--- a/htdocs/product/stock/list.php
+++ b/htdocs/product/stock/list.php
@@ -115,15 +115,15 @@ $arrayfields = array(
 	'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'checked'=>1, 'visible'=>2, 'position'=>172),
 );
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : 'help'
 		);
 	}
 }
diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php
index e5a8b05902e2..92172643096b 100644
--- a/htdocs/product/stock/productlot_list.php
+++ b/htdocs/product/stock/productlot_list.php
@@ -102,15 +102,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = dol_eval($val['visible'], 1);
+		$visible = dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position']
 		);
 	}
 }
 // Extra fields
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 56db0bd2a640..3eeb1bb1e4c0 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -25,10 +25,11 @@
  *      \ingroup    project
  *      \brief      This file is a CRUD class file for Task (Create/Read/Update/Delete)
  */
 
 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
 
 
 /**
  * 	Class to manage tasks
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index cc9099b463bc..36c2fc942b5b 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -180,15 +180,15 @@ $fieldstosearchall['s.nom'] = "ThirdPartyName";
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = dol_eval($val['visible'], 1);
+		$visible = dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['p.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php
index f16b8c3dcf92..05cf56636eaa 100644
--- a/htdocs/recruitment/recruitmentcandidature_list.php
+++ b/htdocs/recruitment/recruitmentcandidature_list.php
@@ -149,15 +149,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of fields for list
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = dol_eval($val['visible'], 1);
+		$visible = dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position']
 		);
 	}
 }
 // Extra fields
diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php
index f0935bc87988..c4a43d0bab4d 100644
--- a/htdocs/recruitment/recruitmentjobposition_list.php
+++ b/htdocs/recruitment/recruitmentjobposition_list.php
@@ -151,15 +151,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php
index 7a8b3ebca103..2e77c29cd01e 100644
--- a/htdocs/salaries/list.php
+++ b/htdocs/salaries/list.php
@@ -132,15 +132,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php
index 77cbae397f0c..58f5546216f8 100644
--- a/htdocs/salaries/payments.php
+++ b/htdocs/salaries/payments.php
@@ -127,15 +127,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php
index b2548807be43..f489c9218fc1 100644
--- a/htdocs/ticket/list.php
+++ b/htdocs/ticket/list.php
@@ -134,15 +134,15 @@ $fieldstosearchall['s.town'] = "Town";
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help'=> isset($val['help']) ? $val['help'] : ''
 		);
 	}
 }
diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php
index 25dcc44de655..0d17232c9db1 100644
--- a/htdocs/workstation/workstation_list.php
+++ b/htdocs/workstation/workstation_list.php
@@ -106,15 +106,15 @@ foreach ($object->fields as $key => $val) {
 // Definition of array of fields for columns
 $arrayfields = array();
 foreach ($object->fields as $key => $val) {
 	// If $val['visible']==0, then we never show the field
 	if (!empty($val['visible'])) {
-		$visible = (int) dol_eval($val['visible'], 1);
+		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
 		$arrayfields['t.'.$key] = array(
 			'label'=>$val['label'],
 			'checked'=>(($visible < 0) ? 0 : 1),
-			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 			'position'=>$val['position'],
 			'help' => empty($val['help']) ? '' : $val['help']
 		);
 	}
 }
@@ -128,11 +128,11 @@ $arrayfields['wug.fk_usergroup'] = array(
 );
 
 $arrayfields['wr.fk_resource'] = array(
 	'label'=>$langs->trans('Resources'),
 	'checked'=>(($visible < 0) ? 0 : 1),
-	'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+	'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
 	'position'=>1001,
 	'help' => empty($val['help']) ? '' : $val['help']
 );
 
 // Extra fields
diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php
index 15e4eaa8bda6..a687e6adbd76 100644
--- a/test/phpunit/SecurityTest.php
+++ b/test/phpunit/SecurityTest.php
@@ -873,15 +873,22 @@ class SecurityTest extends PHPUnit\Framework\TestCase
 		print "result = ".$result."\n";
 		$this->assertFalse($result);
 
 		include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
 		include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
-		$result=dol_eval('(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: "Parent project not found"', 1, 1);
+
+		$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: "Parent project not found"';
+		$result=dol_eval($s, 1, 1, '');
+		print "result = ".$result."\n";
+		$this->assertEquals('Parent project not found', $result);
+
+		$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: \'Parent project not found\'';
+		$result=dol_eval($s, 1, 1, '');
 		print "result = ".$result."\n";
 		$this->assertEquals('Parent project not found', $result);
 
-		$result=dol_eval('$a=function() { }; $a;', 1, 1);
+		$result=dol_eval('$a=function() { }; $a;', 1, 1, '');
 		print "result = ".$result."\n";
 		$this->assertContains('Bad string syntax to evaluate', $result);
 
 		$result=dol_eval('$a=exec("ls");', 1, 1);
 		print "result = ".$result."\n";
@@ -896,7 +903,20 @@ class SecurityTest extends PHPUnit\Framework\TestCase
 		$this->assertContains('Bad string syntax to evaluate', $result);
 
 		$result=dol_eval('`ls`', 1, 0);
 		print "result = ".$result."\n";
 		$this->assertContains('Bad string syntax to evaluate', $result);
+
+		$result=dol_eval("('ex'.'ec')('echo abc')", 1, 0);
+		print "result = ".$result."\n";
+		$this->assertContains('Bad string syntax to evaluate', $result);
+
+		// Case with param onlysimplestring = 1
+		$result=dol_eval('1 && $conf->abc->doesnotexist1 && $conf->def->doesnotexist1', 1, 0);	// Should return false and not a 'Bad string syntax to evaluate ...'
+		print "result = ".$result."\n";
+		$this->assertFalse($result);
+
+		$result=dol_eval("(\$a.'aa')", 1, 0);
+		print "result = ".$result."\n";
+		$this->assertContains('Bad string syntax to evaluate', $result);
 	}
 }

Vulnerable code: 		$visible = dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
				if (!dol_eval($obj->enabled, 1)) {
	print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
		print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
		print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
				'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
				$r = dol_eval($result, 1);
				$r = dol_eval($result, 1);
						$r = dol_eval($result, 1);
						$r = dol_eval($result, 1);
					if (dol_eval($objp->test, 1, 1)) {
				$enabled = dol_eval($this->fields[$key]['enabled'], 1);
				$perms = dol_eval($this->fields[$key]['perms'], 1);
								$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0);
						$value = dol_eval($attrfieldcomputed, 1, 0);
					$value = dol_eval($attrfieldcomputed, 1, 0);
			$value = dol_eval($computed, 1, 0);
						$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1);
						$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1);
						$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1);
			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1);
			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1);
			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1);
			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1);
					$enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1);
					$visibility = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
					$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
				if (!dol_eval($val['enabled'], 1, 1)) {
				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
				if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
				if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
			//if (dol_eval($val['enabled'], 1)) $nb++;
			//if ($key[0] == '$') { return dol_eval($key,1); }
				return dol_eval($key, 1);
	if (dol_eval($val['enabled'], 1)) {
	if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) {
		if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) {
		if (empty($val['measure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) {
				if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) {
 * @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
 * @return	mixed					Nothing or return result of eval
function dol_eval($s, $returnvalue = 0, $hideerrors = 1)
	// Replace dangerous char (used for RCE), we allow only PHP variable testing.
		return 'Bad string syntax to evaluate: '.$s;
	$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask"));
		/*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1)) {
					'checked'  => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1) <= 0) ? 0 : 1),
					'enabled'  => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key], 1)),
					$value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1);
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
			$visible = (int) dol_eval($val['visible'], 1);
				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
			$visible = (int) dol_eval($val['visible'], 1);
				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$visible = (int) dol_eval($val['visible'], 1);
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
	'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
		$result=dol_eval('(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: "Parent project not found"', 1, 1);
		$result=dol_eval('$a=function() { }; $a;', 1, 1);
Fixed code: 		$visible = dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
				if (!dol_eval($obj->enabled, 1, 1, '1')) {
	print ', <span class="opacitymedium">'.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def</span>';
		print ' <span class="opacitymedium">('.$langs->trans("ConditionIsCurrently").':</span> '.yn(dol_eval($menu->enabled, 1, 1, '1')).')';
		print ' <span class="opacitymedium">('.$langs->trans("ConditionIsCurrently").':</span> '.yn(dol_eval($menu->perms, 1, 1, '1')).')';
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
				'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
				$r = dol_eval($result, 1, 1, '1');
				$r = dol_eval($result, 1, 1, 1);
						$r = dol_eval($result, 1, 1, 1);
						$r = dol_eval($result, 1, 1, 1);
					if (dol_eval($objp->test, 1, 1, '')) {
				$enabled = dol_eval($this->fields[$key]['enabled'], 1, 1, '1');
				$perms = dol_eval($this->fields[$key]['perms'], 1, 1, '1');
								$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '');
						$value = dol_eval($attrfieldcomputed, 1, 0, '');
					$value = dol_eval($attrfieldcomputed, 1, 0, '');
			$value = dol_eval($computed, 1, 0, '');
						$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '1');
						$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '1');
						$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '1');
			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1');
			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1');
			$perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1');
			$list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1');
					$enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1, 1, '1');
					$visibility = dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '1');
					$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1, 1, '1');
				if (!dol_eval($val['enabled'], 1, 1, 1, '1')) {
				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1, 1, '1')) {
				if (isset($val['visible']) && !dol_eval($val['visible'], 1, 1, '1')) {
				if (isset($val['enabled']) && !dol_eval($val['enabled'], 1, 1, '1')) {
				if (isset($val['visible']) && !dol_eval($val['visible'], 1, 1, '1')) {
			//if (dol_eval($val['enabled'], 1, 1, '1')) $nb++;
			//if ($key[0] == '$') { return dol_eval($key, 1, 1, '1'); }
				return dol_eval($key, 1, 1, '1');
	if (dol_eval($val['enabled'], 1, 1, '1')) {
	if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
		if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
		if (empty($val['measure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
				if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
 * @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	Accept only simple string with char 'a-z0-9\s$_->&|=';
 * @return	mixed						Nothing or return result of eval
function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1')
	// Test dangerous char (used for RCE), we allow only PHP variable testing.
	if ($onlysimplestring == '1') {
		//print preg_quote('$_->&|', '/');
		if (preg_match('/[^a-z0-9\s'.preg_quote('$_->&|=', '/').']/i', $s)) {
			return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
		}
	}
		return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
	}
	if (strpos($s, '.') !== false) {
		return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
	$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "require", "include", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
		/*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1, 1, '1')) {
					'checked'  => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1') <= 0) ? 0 : 1),
					'enabled'  => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1')),
					$value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1, 1, '0');
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
			$visible = (int) dol_eval($val['visible'], 1, 1, '1');
				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
			$visible = (int) dol_eval($val['visible'], 1, 1, '1');
				'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
		$visible = dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
		$visible = (int) dol_eval($val['visible'], 1, 1, '1');
			'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
	'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),

		$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: "Parent project not found"';
		$result=dol_eval($s, 1, 1, '');
		print "result = ".$result."\n";
		$this->assertEquals('Parent project not found', $result);

		$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: \'Parent project not found\'';
		$result=dol_eval($s, 1, 1, '');
		$result=dol_eval('$a=function() { }; $a;', 1, 1, '');

		$result=dol_eval("('ex'.'ec')('echo abc')", 1, 0);
		print "result = ".$result."\n";
		$this->assertContains('Bad string syntax to evaluate', $result);

		// Case with param onlysimplestring = 1
		$result=dol_eval('1 && $conf->abc->doesnotexist1 && $conf->def->doesnotexist1', 1, 0);	// Should return false and not a 'Bad string syntax to evaluate ...'
		print "result = ".$result."\n";
		$this->assertFalse($result);

		$result=dol_eval("(\$a.'aa')", 1, 0);
		print "result = ".$result."\n";
		$this->assertContains('Bad string syntax to evaluate', $result);