FIX #GHSA-ph29-326p-chw4 - disable+sanitize deprecated load/save files
This commit is contained in:
parent
2bb779fe14
commit
e263a85f89
6 changed files with 36 additions and 14 deletions
|
|
@ -55,7 +55,7 @@ $objecttype = GETPOST('objecttype', 'aZ09arobase');
|
|||
$objectkey = GETPOST('objectkey', 'restricthtml');
|
||||
$search = GETPOST('search', 'restricthtml');
|
||||
$page = GETPOSTINT('page');
|
||||
$mode = GETPOSTINT('mode');
|
||||
$mode = GETPOST('mode', 'aZ09');
|
||||
$value = GETPOST('value', 'alphanohtml');
|
||||
$limit = 10;
|
||||
$offset = (($page - 1) * $limit);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
/**
|
||||
* \file htdocs/core/ajax/ajaxfield.php
|
||||
* \ingroup core
|
||||
* \brief This script returns content of extrafield. See extrafield to update value.
|
||||
* \brief This script returns content of fields or extrafields (using new class/fields/*.class.php files).
|
||||
* TODO This may depreciate htdoc/core/ajax/ajaxextrafields.php
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
|
|
@ -40,15 +41,14 @@ if (!defined('NOHEADERNOFOOTER')) {
|
|||
}
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/fieldsmanager.class.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/fieldsmanager.class.php';
|
||||
|
||||
// object id
|
||||
$objectid = GETPOST('objectid', 'aZ09');
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/ajax/loadinplace.php
|
||||
* \brief File to load field value. used only when option "Edit In Place" is set (MAIN_USE_JQUERY_JEDITABLE).
|
||||
* \file htdocs/core/ajax/loadinplace.php
|
||||
* \brief File to load (loadinplace.php) or update (saveinplace.php) a field value.
|
||||
* Was used in past when option "Edit In Place" is set (MAIN_USE_JQUERY_JEDITABLE).
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/ajax/saveinplace.php
|
||||
* \brief File to load or update field value. Was used in past when option "Edit In Place" is set (MAIN_USE_JQUERY_JEDITABLE).
|
||||
* \file htdocs/core/ajax/saveinplace.php
|
||||
* \brief File to load (loadinplace.php) or update (saveinplace.php) a field value.
|
||||
* Was used in past when option "Edit In Place" is set (MAIN_USE_JQUERY_JEDITABLE).
|
||||
*/
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
|
|
@ -94,6 +95,10 @@ if (!$result) {
|
|||
httponly_accessforbidden('Not allowed by restrictArea');
|
||||
}
|
||||
|
||||
if (!getDolGlobalString('MAIN_USE_JQUERY_JEDITABLE')) {
|
||||
httponly_accessforbidden('Can be used only when option MAIN_USE_JQUERY_JEDITABLE is set');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
|
|
@ -117,7 +122,6 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
|
|||
|
||||
//$savemethod = GETPOST('savemethod', 'alpha', 2);
|
||||
//$savemethodname = (!empty($savemethod) ? $savemethod : 'setValueFrom');
|
||||
$savemethodname = 'setValueFrom';
|
||||
|
||||
$newelement = $element;
|
||||
$subelement = null;
|
||||
|
|
@ -200,7 +204,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
|
|||
$object->fk_element = $fk_element;
|
||||
$object->element = $element;
|
||||
|
||||
$ret = $object->$savemethodname($field, $newvalue, $table_element, (int) $fk_element, $format);
|
||||
$ret = $object->setValueFrom($field, $newvalue, $object->table_element, (int) $fk_element, $format);
|
||||
if ($ret > 0) {
|
||||
if ($type == 'numeric') {
|
||||
$value = price($newvalue);
|
||||
|
|
|
|||
|
|
@ -2238,7 +2238,16 @@ abstract class CommonObject
|
|||
{
|
||||
$result = false;
|
||||
if (!empty($id) && !empty($field) && !empty($table)) {
|
||||
$sql = "SELECT ".$field." FROM ".$this->db->prefix().$table;
|
||||
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $table)) {
|
||||
dol_syslog(get_class($this).'::getValueFrom Bad table name: '.$table, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_.]*$/', $field)) {
|
||||
dol_syslog(get_class($this).'::getValueFrom Bad field name: '.$field, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT ".$this->db->sanitize($field)." FROM ".$this->db->prefix().$this->db->sanitize($table);
|
||||
$sql .= " WHERE rowid = ".((int) $id);
|
||||
|
||||
dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG);
|
||||
|
|
@ -2310,6 +2319,15 @@ abstract class CommonObject
|
|||
$fk_user_field = '';
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $table)) {
|
||||
dol_syslog(get_class($this).'::getValueFrom Bad table name: '.$table, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_.]*$/', $field)) {
|
||||
dol_syslog(get_class($this).'::getValueFrom Bad field name: '.$field, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$oldvalue = null;
|
||||
if ($trigkey) {
|
||||
$sql = "SELECT " . $this->db->sanitize($field);
|
||||
|
|
|
|||
|
|
@ -455,11 +455,10 @@ class FieldsManager
|
|||
*/
|
||||
public function getFieldsInfos($key, &$object, &$extrafields = null, $mode = 'view', $params = array())
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$fieldInfos = null;
|
||||
|
||||
$patternObjectPrefix = getDolGlobalInt('MAIN_FIELDS_NEW_OBJECT_KEY_PREFIX') ? 'object_' : '';
|
||||
$matches = array();
|
||||
if (preg_match('/^options_(.*)/i', $key, $matches)) {
|
||||
$fieldKey = $matches[1];
|
||||
$fieldInfos = $this->getFieldInfosFromExtraField($object, $extrafields, $fieldKey, $mode, $params);
|
||||
|
|
|
|||
Loading…
Reference in a new issue