mirror of
https://github.com/silverstripe/silverstripe-sqlite3
synced 2024-10-22 17:05:37 +02:00
Merge pull request #1 from silverstripe-security/patch/1.4/SS-2017-008
[SS-2017-008] Fix SQL injection in search engine
This commit is contained in:
commit
2bde2640c3
@ -228,6 +228,8 @@ class SQLite3Database extends SS_Database {
|
|||||||
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC",
|
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC",
|
||||||
$extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false
|
$extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false
|
||||||
) {
|
) {
|
||||||
|
$start = (int)$start;
|
||||||
|
$pageLength = (int)$pageLength;
|
||||||
$keywords = $this->escapeString(str_replace(array('*','+','-','"','\''), '', $keywords));
|
$keywords = $this->escapeString(str_replace(array('*','+','-','"','\''), '', $keywords));
|
||||||
$htmlEntityKeywords = htmlentities(utf8_decode($keywords));
|
$htmlEntityKeywords = htmlentities(utf8_decode($keywords));
|
||||||
|
|
||||||
@ -249,7 +251,7 @@ class SQLite3Database extends SS_Database {
|
|||||||
$extraFilters['File'] .= " AND ShowInSearch <> 0";
|
$extraFilters['File'] .= " AND ShowInSearch <> 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit = $start . ", " . (int) $pageLength;
|
$limit = $start . ", " . $pageLength;
|
||||||
|
|
||||||
$notMatch = $invertedMatch ? "NOT " : "";
|
$notMatch = $invertedMatch ? "NOT " : "";
|
||||||
if($keywords) {
|
if($keywords) {
|
||||||
|
Loading…
Reference in New Issue
Block a user