diff --git a/src/SearchServices/Parsers/AbstractSearchParser.php b/src/SearchServices/Parsers/AbstractSearchParser.php index f3490a93..abd72543 100644 --- a/src/SearchServices/Parsers/AbstractSearchParser.php +++ b/src/SearchServices/Parsers/AbstractSearchParser.php @@ -136,7 +136,8 @@ abstract class AbstractSearchParser $tokenText = substr($tokenText, 1); } - if (strpos($tokenText, ':') !== false) + $colonPosition = strpos($tokenText, ':'); + if ($colonPosition !== false and $colonPosition > 0) { $searchToken = new \Szurubooru\SearchServices\Tokens\NamedSearchToken(); list ($tokenKey, $tokenValue) = explode(':', $tokenText, 2); diff --git a/src/Validator.php b/src/Validator.php index b205d093..f6cdf7ba 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -93,9 +93,11 @@ class Validator foreach ($tags as $tag) { if (empty($tag)) - { throw new \DomainException('Tags cannot be empty.'); - } + + //: causes problems with complex search (e.g. id:5). + if (strpos($tag, ':') > 0) + throw new \DomainException('Colon in tag may appear only at the beginning.'); $this->validateMaxLength($tag, 64, 'Tag');