|
From: <var...@us...> - 2021-08-16 09:56:13
|
Revision: 10522
http://sourceforge.net/p/phpwiki/code/10522
Author: vargenau
Date: 2021-08-16 09:56:12 +0000 (Mon, 16 Aug 2021)
Log Message:
-----------
Fix SQL quoting for PDO in search
Modified Paths:
--------------
trunk/lib/WikiDB/backend/PDO.php
Modified: trunk/lib/WikiDB/backend/PDO.php
===================================================================
--- trunk/lib/WikiDB/backend/PDO.php 2021-08-16 08:06:55 UTC (rev 10521)
+++ trunk/lib/WikiDB/backend/PDO.php 2021-08-16 09:56:12 UTC (rev 10522)
@@ -1422,7 +1422,36 @@
class WikiDB_backend_PDO_search extends WikiDB_backend_search_sql
{
- // no surrounding quotes because we know it's a string
+ function _pagename_match_clause($node)
+ {
+ $word = $node->sql();
+ if ($word == '%') { // ALL shortcut
+ return "1=1";
+ } else {
+ $dbh = &$this->_dbh;
+ $word = $dbh->quote($word);
+ return ($this->_case_exact
+ ? "pagename LIKE $word"
+ : "LOWER(pagename) LIKE $word");
+ }
+ }
+
+ function _fulltext_match_clause($node)
+ {
+ // force word-style %word% for fulltext search
+ $dbh = &$this->_dbh;
+ $word = strtolower($node->word);
+ $word = $dbh->quote('%' . $word . '%');
+ // eliminate stoplist words
+ if ($this->isStoplisted($node)) {
+ return "1=1"; // and (pagename or 1) => and 1
+ } else {
+ return $this->_pagename_match_clause($node)
+ // probably convert this MATCH AGAINST or SUBSTR/POSITION without wildcards
+ . ($this->_case_exact ? " OR content LIKE $word"
+ : " OR LOWER(content) LIKE $word");
+ }
+ }
}
// Following function taken from Pear::DB (prev. from adodb-pear.inc.php).
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|