DEV: `tag:` filter on `/filter` only supported alphabets and numbers (#21405)

A tag's name can consist of any Unicode characters as well
This commit is contained in:
Alan Guo Xiang Tan 2023-05-09 08:02:11 +08:00 committed by GitHub
parent 6f26732551
commit 7d0ef338e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -363,7 +363,7 @@ class TopicsFilter
break if key_prefix && key_prefix != "-"
value.scan(
/\A(?<tag_names>([a-zA-Z0-9\-]+)(?<delimiter>[,+])?([a-zA-Z0-9\-]+)?(\k<delimiter>[a-zA-Z0-9\-]+)*)\z/,
/\A(?<tag_names>([\p{N}\p{L}\-]+)(?<delimiter>[,+])?([\p{N}\p{L}\-]+)?(\k<delimiter>[\p{N}\p{L}\-]+)*)\z/,
) do |tag_names, delimiter|
match_all =
if delimiter == ","

View File

@ -869,6 +869,19 @@ RSpec.describe TopicsFilter do
.pluck(:id),
).to contain_exactly(topic_without_tag.id, topic_with_group_only_tag.id)
end
describe "when query string is tag:日べé1" do
before { tag.update!(name: "日べé1") }
it "should return topics that are tagged with the specified tag" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
.filter_from_query_string("tag:日べé1")
.pluck(:id),
).to contain_exactly(topic_with_tag.id, topic_with_tag_and_tag2.id)
end
end
end
describe "when filtering by topic author" do