Fix being able to post URLs longer than 4096 characters

This commit is contained in:
Eugen Rochko 2022-03-22 09:51:46 +01:00
parent ec1bb2a4fe
commit cc706b1191
3 changed files with 58 additions and 14 deletions

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
module Extractor
MAX_DOMAIN_LENGTH = 253
extend Twitter::TwitterText::Extractor
module_function
@ -14,7 +16,12 @@ module Extractor
text.to_s.scan(Account::MENTION_RE) do |screen_name, _|
match_data = $LAST_MATCH_INFO
after = $'
unless Twitter::TwitterText::Regex[:end_mention_match].match?(after)
username, domain = screen_name.split('@')
next if domain.present? && domain.length > MAX_DOMAIN_LENGTH
start_position = match_data.char_begin(1) - 1
end_position = match_data.char_end(1)
possible_entries << {