Merge pull request #697 from pafcu/master
Fix dirsearch parser to not get confused by logic terms in values and to ...
This commit is contained in:
commit
e59f7cc198
@ -282,6 +282,7 @@ function dir_parse_query($s) {
|
|||||||
|
|
||||||
if($all) {
|
if($all) {
|
||||||
foreach($all as $q) {
|
foreach($all as $q) {
|
||||||
|
if($quoted_string === false) {
|
||||||
if($q === 'and') {
|
if($q === 'and') {
|
||||||
$curr['logic'] = 'and';
|
$curr['logic'] = 'and';
|
||||||
continue;
|
continue;
|
||||||
@ -299,18 +300,20 @@ function dir_parse_query($s) {
|
|||||||
$curr['logic'] = 'or';
|
$curr['logic'] = 'or';
|
||||||
$curr['field'] = trim(substr($q,0,strpos($q,'=')));
|
$curr['field'] = trim(substr($q,0,strpos($q,'=')));
|
||||||
$curr['value'] = trim(substr($q,strpos($q,'=')+1));
|
$curr['value'] = trim(substr($q,strpos($q,'=')+1));
|
||||||
if(strpos($curr['value'],'"') !== false) {
|
if($curr['value'][0] == '"' && $curr['value'][strlen($curr['value'])-1] != '"') {
|
||||||
$quoted_string = true;
|
$quoted_string = true;
|
||||||
$curr['value'] = substr($curr['value'],strpos($curr['value'],'"')+1);
|
$curr['value'] = substr($curr['value'],1);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ret[] = $curr;
|
$ret[] = $curr;
|
||||||
$curr = array();
|
$curr = array();
|
||||||
$continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($quoted_string) {
|
}
|
||||||
if(strpos($q,'"') !== false) {
|
else {
|
||||||
|
if($q[strlen($q)-1] == '"') {
|
||||||
$curr['value'] .= ' ' . str_replace('"','',trim($q));
|
$curr['value'] .= ' ' . str_replace('"','',trim($q));
|
||||||
$ret[] = $curr;
|
$ret[] = $curr;
|
||||||
$curr = array();
|
$curr = array();
|
||||||
|
Reference in New Issue
Block a user