about summary refs log tree commit diff
path: root/app/lib/extractor.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-03-30 14:46:03 +0200
committerGitHub <noreply@github.com>2022-03-30 14:46:03 +0200
commitbbc7afa2a24519ac238cbcd4e8aec310a002c40e (patch)
tree1fa3182233d71a2f6897f50d6b180d4c502b1fd1 /app/lib/extractor.rb
parent5554ff2a1d6f451d63d03f4eb0a740d8c91455de (diff)
Fix being able to post URLs longer than 4096 characters (#17908)
Diffstat (limited to 'app/lib/extractor.rb')
-rw-r--r--app/lib/extractor.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/lib/extractor.rb b/app/lib/extractor.rb
index ef9407864..aea60dae5 100644
--- a/app/lib/extractor.rb
+++ b/app/lib/extractor.rb
@@ -1,6 +1,8 @@
 # frozen_string_literal: true
 
 module Extractor
+  MAX_DOMAIN_LENGTH = 253
+
   extend Twitter::TwitterText::Extractor
 
   module_function
@@ -30,6 +32,10 @@ module Extractor
       after      = $'
 
       unless Twitter::TwitterText::Regex[:end_mention_match].match?(after)
+        _, 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)