diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 01c60780074972f691700d36c85ab8ff425d3ee2..44a234d849931fa647e8f1f54c95e825ff9c872f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1579,13 +1579,13 @@ class Form foreach ($scrit as $crit) { if ($i > 0) $sql.=" AND "; - $sql.="(p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%'"; - if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$prefix.$crit."%'"; + $sql.="(p.ref LIKE '".$db->escape($prefix.$crit)."%' OR p.label LIKE '".$db->escape($prefix.$crit)."%'"; + if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$db->escape($prefix.$crit)."%'"; $sql.=")"; $i++; } if (count($scrit) > 1) $sql.=")"; - if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'"; + if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'"; $sql.=')'; } $sql.= $db->order("p.ref"); @@ -1933,7 +1933,7 @@ class Form $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; $sql.= " AND p.tobuy = 1"; - if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype; + if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$this->db->escape($filtertype); if (! empty($filtre)) $sql.=" ".$filtre; // Add criteria on ref/label if ($filterkey != '') @@ -1947,11 +1947,11 @@ class Form foreach ($scrit as $crit) { if ($i > 0) $sql.=" AND "; - $sql.="(pfp.ref_fourn LIKE '".$prefix.$crit."%' OR p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%')"; + $sql.="(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')"; $i++; } if (count($scrit) > 1) $sql.=")"; - if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'"; + if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; $sql.=')'; } $sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 7dda37b6f2c7b65d7f1776f2488578f473839f0d..0d4cbda9fc2a35ccb0e4c76e21609668cfe711e7 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -169,8 +169,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET)); sort($match); - $idprod = (! empty($match [0]) ? $match [0] : ''); + $idprod = (! empty($match[0]) ? $match[0] : ''); + if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5b969023cb576422ea4a5d8f5e23cecf1a7a59b6..6c8f8613b55109052f73c3389a690a6ceee36c47 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2867,7 +2867,7 @@ class Product extends CommonObject { global $langs; $langs->load('products'); - if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); + if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); if ($type == 2) {