diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ac465b16bd7..ba1bc47046f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -93,7 +93,11 @@ $refalreadyexists = 0; // Get parameters $id = GETPOST('id', 'int'); -$ref = (GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : null); +if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) { + $ref = (GETPOSTISSET('ref') ? GETPOST('ref', 'nohtml') : null); +} else { + $ref = (GETPOSTISSET('ref') ? GETPOST('ref', 'alpha') : null); +} $type = (GETPOSTISSET('type') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT); $action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $cancel = GETPOST('cancel', 'alpha'); @@ -113,7 +117,11 @@ $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); $checkmandatory = GETPOST('accountancy_code_buy_export', 'alpha'); // by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html -$label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml'; +if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) { + $label_security_check = 'nohtml'; +} else { + $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml'; +} if (!empty($user->socid)) { $socid = $user->socid; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d464871941a..1a2b3fa4cf2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -572,7 +572,11 @@ class Product extends CommonObject */ public function check() { - $this->ref = dol_sanitizeFileName(stripslashes($this->ref)); + if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) { + $this->ref = trim($this->ref); + } else { + $this->ref = dol_sanitizeFileName(stripslashes($this->ref)); + } $err = 0; if (dol_strlen(trim($this->ref)) == 0) { @@ -604,7 +608,11 @@ class Product extends CommonObject $error = 0; // Clean parameters - $this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref))); + if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) { + $this->ref = trim($this->ref); + } else { + $this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref))); + } $this->label = trim($this->label); $this->price_ttc = price2num($this->price_ttc); $this->price = price2num($this->price); @@ -999,7 +1007,11 @@ class Product extends CommonObject } // Clean parameters - $this->ref = dol_string_nospecial(trim($this->ref)); + if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) { + $this->ref = trim($this->ref); + } else { + $this->ref = dol_string_nospecial(trim($this->ref)); + } $this->label = trim($this->label); $this->description = trim($this->description); $this->note_private = (isset($this->note_private) ? trim($this->note_private) : null);