Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into 15.0
This commit is contained in:
commit
fa05dc44ce
2 changed files with 17 additions and 14 deletions
|
|
@ -121,19 +121,17 @@ abstract class DoliDB implements Database
|
|||
}
|
||||
|
||||
/**
|
||||
* Sanitize a string for SQL forging
|
||||
*
|
||||
* @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', ...)
|
||||
* @return string String escaped
|
||||
*/
|
||||
public function sanitize($stringtosanitize, $allowsimplequote = 0)
|
||||
* Sanitize a string for SQL forging
|
||||
*
|
||||
* @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 int $allowsequals 1=Allow equals sign
|
||||
* @param int $allowsspace 1=Allow space char
|
||||
* @return string String escaped
|
||||
*/
|
||||
public function sanitize($stringtosanitize, $allowsimplequote = 0, $allowsequals = 0, $allowsspace = 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 ? "\'" : '').($allowsspace ? ' ' : '').']/i', '', $stringtosanitize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9022,7 +9022,12 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
|
|||
|
||||
$value = preg_replace('/\s*\|\s*/', '|', $value);
|
||||
|
||||
$crits = explode(' ', $value);
|
||||
//natural mode search type 3 allow spaces into search ...
|
||||
if ($mode == 3 || $mode == -3) {
|
||||
$crits = explode(',', $value);
|
||||
} else {
|
||||
$crits = explode(' ', $value);
|
||||
}
|
||||
$res = '';
|
||||
if (!is_array($fields)) {
|
||||
$fields = array($fields);
|
||||
|
|
@ -9072,7 +9077,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
|
|||
$listofcodes .= "'".$db->escape($val)."'";
|
||||
}
|
||||
}
|
||||
$newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1).")";
|
||||
$newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1, 0, 1).")";
|
||||
$i2++; // a criteria was added to string
|
||||
}
|
||||
if ($mode == -3) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue