From 7fc0cd7631fcc33ce62d6493c2c15986a632fe9f Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 5 Oct 2014 20:55:10 +0200 Subject: [PATCH] Fixed problems with colons in tags --- src/SearchServices/Parsers/AbstractSearchParser.php | 3 ++- src/Validator.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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');