Skip to content

Commit

Permalink
Prevent +/- operators (REGEXP) on glossary searches for MSSQL and Ora…
Browse files Browse the repository at this point in the history
…cle. MDL-7312

Merged from MOODLE_17_STABLE
  • Loading branch information
stronk7 committed Oct 31, 2006
1 parent b4a1805 commit 6f4bdb9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]|$)' ";
Expand Down
7 changes: 7 additions & 0 deletions mod/glossary/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]|$)' ";
Expand Down

0 comments on commit 6f4bdb9

Please sign in to comment.