Use TwitterText regex for valid domains in mentions

TwitterText already has a regex to check for valid domains that allows a
few domains the current Regex did not allow. Mainly it allows mentions
of accounts on domains with emoji in their domain names to be processed
correctly.

Mentions like `@test@🌈🌈🌈.st` will now work correctly.
This commit is contained in:
Mischa Holz 2023-07-10 21:38:00 +02:00
parent 4de108e755
commit 1b909c98ab
No known key found for this signature in database
GPG Key ID: A6331083697F81DF

View File

@ -71,7 +71,7 @@ class Account < ApplicationRecord
INSTANCE_ACTOR_ID = -99
USERNAME_RE = /[a-z0-9_]+([.-]+[a-z0-9_]+)*/i
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]]+([.-]+[[:word:]]+)*)?)}
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@#{Twitter::TwitterText::Regex[:valid_domain]})?)}
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i
USERNAME_LENGTH_LIMIT = 30