posts: fix exception when searching for "-" or "~".

This commit is contained in:
evazion
2020-03-31 20:51:06 -05:00
parent ab1839c613
commit 0aa8e16113
2 changed files with 10 additions and 1 deletions

View File

@@ -1038,7 +1038,9 @@ class PostQueryBuilder
def parse_tag(tag, output)
operator, tag = parse_tag_operator(tag)
if tag.include?("*")
if tag.blank?
# XXX ignore "-", "~" operators without a tag.
elsif tag.include?("*")
tags = Tag.wildcard_matches(tag)
if operator == "-"

View File

@@ -1962,6 +1962,13 @@ class PostTest < ActiveSupport::TestCase
assert_tag_match([post2], "-*c -a*a")
end
should "ignore invalid operator syntax" do
assert_nothing_raised do
assert_tag_match([], "-")
assert_tag_match([], "~")
end
end
should "return posts for the id:<N> metatag" do
posts = FactoryBot.create_list(:post, 3)