diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 6d775eb92..1340d07d7 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -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 == "-" diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index b4c706c1a..a282efd9a 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -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: metatag" do posts = FactoryBot.create_list(:post, 3)