mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Prevent +/- operators (REGEXP) on glossary searches for MSSQL and Oracle. MDL-7312
Merged from MOODLE_17_STABLE
This commit is contained in:
parent
b4a1805ab0
commit
6f4bdb9c9b
2 changed files with 13 additions and 0 deletions
|
@ -987,6 +987,12 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
|
|||
$definitionsearch.= " OR ";
|
||||
}
|
||||
|
||||
/// Under Oracle and MSSQL, trim the + and - operators and perform
|
||||
/// simpler LIKE search
|
||||
if ($CFG->dbtype == 'oci8po' || $CFG->dbtype == 'mssql' || $CFG->dbtype == 'mssql_n' || $CFG->dbtype == 'odbc_mssql') {
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
}
|
||||
|
||||
if (substr($searchterm,0,1) == "+") {
|
||||
$searchterm = substr($searchterm,1);
|
||||
$conceptsearch.= " e.concept $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
|
|
|
@ -160,6 +160,13 @@
|
|||
if ($definitionsearch) {
|
||||
$definitionsearch .= " AND ";
|
||||
}
|
||||
|
||||
/// Under Oracle and MSSQL, trim the + and - operators and perform
|
||||
/// simpler LIKE search
|
||||
if ($CFG->dbtype == 'oci8po' || $CFG->dbtype == 'mssql' || $CFG->dbtype == 'mssql_n' || $CFG->dbtype == 'odbc_mssql') {
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
}
|
||||
|
||||
if (substr($searchterm,0,1) == "+") {
|
||||
$searchterm = substr($searchterm,1);
|
||||
$conceptsearch .= " ge.concept $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue