FIX: Support unicode in search filter @username (#18804)
This commit is contained in:
parent
5b16546358
commit
41e6b516e5
|
@ -646,10 +646,10 @@ class Search
|
|||
end
|
||||
end
|
||||
|
||||
advanced_filter(/^\@([a-zA-Z0-9_\-.]+)$/i) do |posts, match|
|
||||
username = match.downcase
|
||||
advanced_filter(/^\@(\S+)$/i) do |posts, match|
|
||||
username = User.normalize_username(match)
|
||||
|
||||
user_id = User.where(staged: false).where(username_lower: username).pluck_first(:id)
|
||||
user_id = User.not_staged.where(username_lower: username).pluck_first(:id)
|
||||
|
||||
if !user_id && username == "me"
|
||||
user_id = @guardian.user&.id
|
||||
|
|
|
@ -1597,6 +1597,12 @@ RSpec.describe Search do
|
|||
expect(Search.execute("user:#{post_1.user_id}").posts).to contain_exactly(post_1)
|
||||
|
||||
expect(Search.execute("@#{post_1.user.username}").posts).to contain_exactly(post_1)
|
||||
|
||||
SiteSetting.unicode_usernames = true
|
||||
unicode_user = Fabricate(:unicode_user)
|
||||
post_3 = Fabricate(:post, user: unicode_user, raw: 'post by a unicode user', topic: topic)
|
||||
|
||||
expect(Search.execute("@#{post_3.user.username}").posts).to contain_exactly(post_3)
|
||||
end
|
||||
|
||||
context "when searching for posts made by users of a group" do
|
||||
|
|
Loading…
Reference in New Issue