diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index aedff703a19..430c3a708d2 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -188,7 +188,7 @@ class FormProjets
$sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
}
if ($morefilter) {
- $sql .= ' AND ('.$morefilter.')';
+ $sql .= ' AND ('.$this->db->sanitize($morefilter, 0, 1).')';
}
$sql .= " ORDER BY p.ref ASC";
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index 2d2ea33a6c5..16b2fd956fe 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -136,15 +136,12 @@ abstract class DoliDB implements Database
*
* @param string $stringtosanitize String to escape
* @param int $allowsimplequote 1=Allow simple quotes in string. When string is used as a list of SQL string ('aa', 'bb', ...)
+ * @param string $allowsequals 1=Allow equals sign
* @return string String escaped
*/
- public function sanitize($stringtosanitize, $allowsimplequote = 0)
+ public function sanitize($stringtosanitize, $allowsimplequote = 0, $allowsequals = 0)
{
- if ($allowsimplequote) {
- return preg_replace('/[^a-z0-9_\-\.,\']/i', '', $stringtosanitize);
- } else {
- return preg_replace('/[^a-z0-9_\-\.,]/i', '', $stringtosanitize);
- }
+ return preg_replace('/[^a-z0-9_\-\.,'.($allowsequals ? '=' : '').($allowsimplequote ? "\'" : '').']/i', '', $stringtosanitize);
}
/**