From: <ru...@us...> - 2009-10-12 10:41:36
|
Revision: 7203 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7203&view=rev Author: rurban Date: 2009-10-12 10:41:27 +0000 (Mon, 12 Oct 2009) Log Message: ----------- Prioritize search regex "not*" over keyword "not", ditto for "and" and "or". Search for "not*" will now find "*Note" and "*Notes" Modified Paths: -------------- trunk/lib/TextSearchQuery.php Modified: trunk/lib/TextSearchQuery.php =================================================================== --- trunk/lib/TextSearchQuery.php 2009-10-11 14:18:08 UTC (rev 7202) +++ trunk/lib/TextSearchQuery.php 2009-10-12 10:41:27 UTC (rev 7203) @@ -1104,19 +1104,10 @@ $tokens = array(); $buf = $case_exact ? ltrim($string) : strtolower(ltrim($string)); while (!empty($buf)) { - if (preg_match('/^(and|or)\b\s*/i', $buf, $m)) { - $val = strtolower($m[1]); - $type = TSQ_TOK_BINOP; - } - elseif (preg_match('/^(-|not\b)\s*/i', $buf, $m)) { - $val = strtolower($m[1]); - $type = TSQ_TOK_NOT; - } - elseif (preg_match('/^([()])\s*/', $buf, $m)) { + if (preg_match('/^([()])\s*/', $buf, $m)) { $val = $m[1]; $type = $m[1] == '(' ? TSQ_TOK_LPAREN : TSQ_TOK_RPAREN; } - // * => ALL elseif ($regex & (TSQ_REGEX_AUTO|TSQ_REGEX_POSIX|TSQ_REGEX_GLOB) and preg_match('/^\*\s*/', $buf, $m)) { @@ -1166,6 +1157,14 @@ $val = $m[1]; $type = TSQ_TOK_EXACT; } + elseif (preg_match('/^(and|or)\b\s*/i', $buf, $m)) { + $val = strtolower($m[1]); + $type = TSQ_TOK_BINOP; + } + elseif (preg_match('/^(-|not\b)\s*/i', $buf, $m)) { + $val = strtolower($m[1]); + $type = TSQ_TOK_NOT; + } // "words " elseif (preg_match('/^ " ( (?: [^"]+ | "" )* ) " \s*/x', $buf, $m)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2010-04-15 10:10:48
|
Revision: 7334 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7334&view=rev Author: vargenau Date: 2010-04-15 10:10:42 +0000 (Thu, 15 Apr 2010) Log Message: ----------- Remove assert since assert fails in debug mode for some URLs Modified Paths: -------------- trunk/lib/TextSearchQuery.php Modified: trunk/lib/TextSearchQuery.php =================================================================== --- trunk/lib/TextSearchQuery.php 2010-04-15 10:01:45 UTC (rev 7333) +++ trunk/lib/TextSearchQuery.php 2010-04-15 10:10:42 UTC (rev 7334) @@ -962,7 +962,9 @@ $this->lexer = new TextSearchQuery_Lexer($search_expr, $case_exact, $regex); $this->_regex = $regex; $tree = $this->get_list('toplevel'); - assert($this->lexer->eof()); + // Assert failure when using the following URL in debug mode. + // /TitleSearch?action=FullTextSearch&s=WFXSSProbe'")/>&case_exact=1®ex=sql + // assert($this->lexer->eof()); unset($this->lexer); return $tree; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-07-15 16:37:08
|
Revision: 8963 http://sourceforge.net/p/phpwiki/code/8963 Author: vargenau Date: 2014-07-15 16:37:05 +0000 (Tue, 15 Jul 2014) Log Message: ----------- Add braces Modified Paths: -------------- trunk/lib/TextSearchQuery.php Modified: trunk/lib/TextSearchQuery.php =================================================================== --- trunk/lib/TextSearchQuery.php 2014-07-15 12:28:16 UTC (rev 8962) +++ trunk/lib/TextSearchQuery.php 2014-07-15 16:37:05 UTC (rev 8963) @@ -96,10 +96,11 @@ */ function TextSearchQuery($search_query, $case_exact = false, $regex = 'auto') { - if ($regex == 'none' or !$regex) + if ($regex == 'none' or !$regex) { $this->_regex = 0; - elseif (defined("TSQ_REGEX_" . strtoupper($regex))) - $this->_regex = constant("TSQ_REGEX_" . strtoupper($regex)); else { + } elseif (defined("TSQ_REGEX_" . strtoupper($regex))) { + $this->_regex = constant("TSQ_REGEX_" . strtoupper($regex)); + } else { trigger_error(fmt("Unsupported argument: %s=%s", 'regex', $regex)); $this->_regex = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-10-03 14:47:40
|
Revision: 9178 http://sourceforge.net/p/phpwiki/code/9178 Author: vargenau Date: 2014-10-03 14:47:32 +0000 (Fri, 03 Oct 2014) Log Message: ----------- function token_get_all exists Modified Paths: -------------- trunk/lib/TextSearchQuery.php Modified: trunk/lib/TextSearchQuery.php =================================================================== --- trunk/lib/TextSearchQuery.php 2014-10-03 14:43:00 UTC (rev 9177) +++ trunk/lib/TextSearchQuery.php 2014-10-03 14:47:32 UTC (rev 9178) @@ -419,49 +419,28 @@ } // Strictly check for illegal functions and operators, which are no placeholders. - if (function_exists('token_get_all')) { - $parsed = token_get_all("<?$query?>"); - foreach ($parsed as $x) { // flat, non-recursive array - if (is_string($x) and !isset($this->_parser_check[$x])) { - // single char op or name - trigger_error("Illegal string or operator in query: \"$x\"", E_USER_WARNING); + $parsed = token_get_all("<?$query?>"); + foreach ($parsed as $x) { // flat, non-recursive array + if (is_string($x) and !isset($this->_parser_check[$x])) { + // single char op or name + trigger_error("Illegal string or operator in query: \"$x\"", E_USER_WARNING); + $query = ''; + } elseif (is_array($x)) { + $n = token_name($x[0]); + if ($n == 'T_OPEN_TAG' or $n == 'T_WHITESPACE' + or $n == 'T_CLOSE_TAG' or $n == 'T_LNUMBER' + or $n == 'T_CONST' or $n == 'T_DNUMBER' + ) continue; + if ($n == 'T_VARIABLE') { // but we do allow consts + trigger_error("Illegal variable in query: \"$x[1]\"", E_USER_WARNING); $query = ''; - } elseif (is_array($x)) { - $n = token_name($x[0]); - if ($n == 'T_OPEN_TAG' or $n == 'T_WHITESPACE' - or $n == 'T_CLOSE_TAG' or $n == 'T_LNUMBER' - or $n == 'T_CONST' or $n == 'T_DNUMBER' - ) continue; - if ($n == 'T_VARIABLE') { // but we do allow consts - trigger_error("Illegal variable in query: \"$x[1]\"", E_USER_WARNING); - $query = ''; - } - if (is_string($x[1]) and !isset($this->_parser_check[$x[1]])) { - // multi-char char op or name - trigger_error("Illegal $n in query: \"$x[1]\"", E_USER_WARNING); - $query = ''; - } } + if (is_string($x[1]) and !isset($this->_parser_check[$x[1]])) { + // multi-char char op or name + trigger_error("Illegal $n in query: \"$x[1]\"", E_USER_WARNING); + $query = ''; + } } - //echo "$query <br>"; - //$this->_parse_token($parsed); - //echo "<br>\n"; - //var_dump($parsed); - /* - "_x > 0" => - { T_OPEN_TAG "<?"} { T_STRING "_x"} { T_WHITESPACE " "} ">" { T_WHITESPACE " "} { T_LNUMBER "0"} { T_CLOSE_TAG "?>"} - Interesting: on-char ops, as ">" are not tokenized. - "_x <= 0" - { T_OPEN_TAG "< ?" } { T_STRING "_x" } { T_WHITESPACE " " } { T_IS_SMALLER_OR_EQUAL "<=" } { T_WHITESPACE " " } { T_LNUMBER "0" } { T_CLOSE_TAG "?>" } - */ - } else { - // Detect illegal characters besides nums, words and ops. - // So attribute names can not be utf-8 - $c = "/([^\d\w.,\s" . preg_quote(join("", $this->_allowed_operators), "/") . "])/"; - if (preg_match($c, $query, $m)) { - trigger_error("Illegal character in query: " . $m[1], E_USER_WARNING); - return ''; - } } return $query; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2015-03-02 17:27:19
|
Revision: 9586 http://sourceforge.net/p/phpwiki/code/9586 Author: vargenau Date: 2015-03-02 17:27:12 +0000 (Mon, 02 Mar 2015) Log Message: ----------- Fix crash with use of "-" in search Modified Paths: -------------- trunk/lib/TextSearchQuery.php Modified: trunk/lib/TextSearchQuery.php =================================================================== --- trunk/lib/TextSearchQuery.php 2015-03-02 17:21:46 UTC (rev 9585) +++ trunk/lib/TextSearchQuery.php 2015-03-02 17:27:12 UTC (rev 9586) @@ -244,7 +244,7 @@ // TODO: "such a phrase" switch ($node->_op) { case TSQ_TOK_NOT: - return "!" . $node->leaves[0]; + return "!" . $node->leaves[0]->word; case TSQ_TOK_BINOP: $subclauses = array(); foreach ($node->leaves as $leaf) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-20 12:34:59
|
Revision: 10592 http://sourceforge.net/p/phpwiki/code/10592 Author: vargenau Date: 2021-09-20 12:34:57 +0000 (Mon, 20 Sep 2021) Log Message: ----------- sql_quote has no parameter Modified Paths: -------------- trunk/lib/TextSearchQuery.php Modified: trunk/lib/TextSearchQuery.php =================================================================== --- trunk/lib/TextSearchQuery.php 2021-09-20 12:26:39 UTC (rev 10591) +++ trunk/lib/TextSearchQuery.php 2021-09-20 12:34:57 UTC (rev 10592) @@ -662,7 +662,7 @@ function sql() { - return '%' . $this->sql_quote($this->word) . '%'; + return '%' . $this->sql_quote() . '%'; } } @@ -696,7 +696,7 @@ function sql() { - return $this->sql_quote($this->word) . '%'; + return $this->sql_quote() . '%'; } } @@ -723,7 +723,7 @@ function sql() { - return '%' . $this->sql_quote($this->word); + return '%' . $this->sql_quote(); } } @@ -767,7 +767,7 @@ function sql() { - return $this->sql_quote($this->word); + return $this->sql_quote(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |