From 5dc690af9eefe5648dac7f9996c8c34670f7ee9f Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 12 Oct 2017 11:57:26 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#381 where Selectors class could get confused by a quoted value with comma when contained in an OR value --- wire/core/Selectors.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wire/core/Selectors.php b/wire/core/Selectors.php index d330bf5c..7858ae19 100644 --- a/wire/core/Selectors.php +++ b/wire/core/Selectors.php @@ -516,8 +516,18 @@ class Selectors extends WireArray { if($commaPos === false && $closingQuote) { // if closing quote and comma didn't match, try to match just comma in case of "something", - $commaPos = strpos(substr($str, 1), ','); - if($commaPos !== false) $commaPos++; + $str1 = substr($str, 1); + $commaPos = strpos($str1, ','); + if($commaPos !== false) { + $closingQuotePos = strpos($str1, $closingQuote); + if($closingQuotePos > $commaPos) { + // comma is in quotes and thus not one we want to work with + return false; + } else { + // increment by 1 since it was derived from a string at position 1 (rather than 0) + $commaPos++; + } + } } if($commaPos === false) {