]> cat aescling's git repositories - mastodon.git/commitdiff
Fix announcements with fully-qualified mention to local user crashing WebUI (#13164)
authorThibG <thib@sitedethib.com>
Fri, 28 Feb 2020 12:49:45 +0000 (13:49 +0100)
committerGitHub <noreply@github.com>
Fri, 28 Feb 2020 12:49:45 +0000 (13:49 +0100)
app/models/account.rb

index 0eb719d652a7d69fbd64a10c575e36a818243d87..778429b0d8c65f78588cbee2a684e6ae1db0ecdd 100644 (file)
@@ -478,7 +478,16 @@ class Account < ApplicationRecord
     def from_text(text)
       return [] if text.blank?
 
-      text.scan(MENTION_RE).map { |match| match.first.split('@', 2) }.uniq.map { |(username, domain)| EntityCache.instance.mention(username, domain) }
+      text.scan(MENTION_RE).map { |match| match.first.split('@', 2) }.uniq.map do |(username, domain)|
+        domain = begin
+          if TagManager.instance.local_domain?(domain)
+            nil
+          else
+            TagManager.instance.normalize_domain(domain)
+          end
+        end
+        EntityCache.instance.mention(username, domain)
+      end.compact
     end
 
     private