1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 11:44:42 +02:00

Improve operator extraction in Selectors class so that it doesn't potentially match non-existent operators and throw an unnecessary "unknown operator - selector value property escaped?" error message

This commit is contained in:
Ryan Cramer
2019-06-20 10:41:21 -04:00
parent fdc1c61833
commit 734c56dbbe

View File

@@ -531,8 +531,15 @@ class Selectors extends WireArray {
protected function extractOperator(&$str, array $operatorChars) { protected function extractOperator(&$str, array $operatorChars) {
$n = 0; $n = 0;
$operator = ''; $operator = '';
$lastOperator = '';
while(isset($str[$n]) && in_array($str[$n], $operatorChars) && $n < self::maxOperatorLength) { while(isset($str[$n]) && in_array($str[$n], $operatorChars) && $n < self::maxOperatorLength) {
$operator .= $str[$n]; $operator .= $str[$n];
if(self::isOperator($operator)) {
$lastOperator = $operator;
} else if($lastOperator) {
$operator = $lastOperator;
break;
}
$n++; $n++;
} }
if($operator) $str = substr($str, $n); if($operator) $str = substr($str, $n);