Fixed problems with colons in tags

This commit is contained in:
Marcin Kurczewski 2014-10-05 20:55:10 +02:00
parent 66535f6142
commit 7fc0cd7631
2 changed files with 6 additions and 3 deletions

View file

@ -136,7 +136,8 @@ abstract class AbstractSearchParser
$tokenText = substr($tokenText, 1); $tokenText = substr($tokenText, 1);
} }
if (strpos($tokenText, ':') !== false) $colonPosition = strpos($tokenText, ':');
if ($colonPosition !== false and $colonPosition > 0)
{ {
$searchToken = new \Szurubooru\SearchServices\Tokens\NamedSearchToken(); $searchToken = new \Szurubooru\SearchServices\Tokens\NamedSearchToken();
list ($tokenKey, $tokenValue) = explode(':', $tokenText, 2); list ($tokenKey, $tokenValue) = explode(':', $tokenText, 2);

View file

@ -93,9 +93,11 @@ class Validator
foreach ($tags as $tag) foreach ($tags as $tag)
{ {
if (empty($tag)) if (empty($tag))
{
throw new \DomainException('Tags cannot be empty.'); 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'); $this->validateMaxLength($tag, 64, 'Tag');