aboutsummaryrefslogtreecommitdiffstats
path: root/mod/dirsearch.php
diff options
context:
space:
mode:
authorStefan Parviainen <saparvia@caterva.eu>2014-11-17 18:51:37 +0100
committerStefan Parviainen <saparvia@caterva.eu>2014-11-17 18:51:37 +0100
commitece9819b4d830296474c05bb89161266f6298405 (patch)
tree2ead7d2ace78671c827740f81f1d05d32dbdbf84 /mod/dirsearch.php
parente190adc58980c12c6dffb21dae57194aad354e3c (diff)
downloadvolse-hubzilla-ece9819b4d830296474c05bb89161266f6298405.tar.gz
volse-hubzilla-ece9819b4d830296474c05bb89161266f6298405.tar.bz2
volse-hubzilla-ece9819b4d830296474c05bb89161266f6298405.zip
Fix dirsearch parser to not get confused by logic terms in names and to handle quoted single word names
Diffstat (limited to 'mod/dirsearch.php')
-rw-r--r--mod/dirsearch.php53
1 files changed, 28 insertions, 25 deletions
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index dea34c566..52d953707 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -282,35 +282,38 @@ function dir_parse_query($s) {
if($all) {
foreach($all as $q) {
- if($q === 'and') {
- $curr['logic'] = 'and';
- continue;
- }
- if($q === 'or') {
- $curr['logic'] = 'or';
- continue;
- }
- if($q === 'not') {
- $curr['logic'] .= ' not';
- continue;
- }
- if(strpos($q,'=')) {
- if(! isset($curr['logic']))
+ if($quoted_string === false) {
+ if($q === 'and') {
+ $curr['logic'] = 'and';
+ continue;
+ }
+ if($q === 'or') {
$curr['logic'] = 'or';
- $curr['field'] = trim(substr($q,0,strpos($q,'=')));
- $curr['value'] = trim(substr($q,strpos($q,'=')+1));
- if(strpos($curr['value'],'"') !== false) {
- $quoted_string = true;
- $curr['value'] = substr($curr['value'],strpos($curr['value'],'"')+1);
+ continue;
}
- else {
- $ret[] = $curr;
- $curr = array();
- $continue;
+ if($q === 'not') {
+ $curr['logic'] .= ' not';
+ continue;
+ }
+ if(strpos($q,'=')) {
+ if(! isset($curr['logic']))
+ $curr['logic'] = 'or';
+ $curr['field'] = trim(substr($q,0,strpos($q,'=')));
+ $curr['value'] = trim(substr($q,strpos($q,'=')+1));
+ if($curr['value'][0] == '"' && $curr['value'][strlen($curr['value'])-1] != '"') {
+ $quoted_string = true;
+ $curr['value'] = substr($curr['value'],1);
+ continue;
+ }
+ else {
+ $ret[] = $curr;
+ $curr = array();
+ continue;
+ }
}
}
- elseif($quoted_string) {
- if(strpos($q,'"') !== false) {
+ else {
+ if($q[strlen($q)-1] == '"') {
$curr['value'] .= ' ' . str_replace('"','',trim($q));
$ret[] = $curr;
$curr = array();