about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-07-31 05:06:20 +0200
committerGitHub <noreply@github.com>2017-07-31 05:06:20 +0200
commite1fcad34a9e3c3fd22b3bee66b82d85bd03629fb (patch)
treee681a8d0fb6ba45b6209485f2de391c1c59028aa /app
parent155ba8fd3a5300b68cb968520d082920a81165fa (diff)
Fix length validator counting things that look like URIs like URLs (#4462)
URI.extract is too strong, not limited to URLs, matched real text.
Same issue was present in language detector.
Diffstat (limited to 'app')
-rw-r--r--app/lib/language_detector.rb4
-rw-r--r--app/validators/status_length_validator.rb2
2 files changed, 2 insertions, 4 deletions
diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb
index 6d6ae2fb3..cc7509fdc 100644
--- a/app/lib/language_detector.rb
+++ b/app/lib/language_detector.rb
@@ -33,9 +33,7 @@ class LanguageDetector
 
   def simplified_text
     text.dup.tap do |new_text|
-      URI.extract(new_text).each do |url|
-        new_text.gsub!(url, '')
-      end
+      new_text.gsub!(FetchLinkCardService::URL_PATTERN, '')
       new_text.gsub!(Account::MENTION_RE, '')
       new_text.gsub!(Tag::HASHTAG_RE, '')
       new_text.gsub!(/\s+/, ' ')
diff --git a/app/validators/status_length_validator.rb b/app/validators/status_length_validator.rb
index abf250d65..77be3f1f5 100644
--- a/app/validators/status_length_validator.rb
+++ b/app/validators/status_length_validator.rb
@@ -24,7 +24,7 @@ class StatusLengthValidator < ActiveModel::Validator
 
   def countable_text(status)
     status.text.dup.tap do |new_text|
-      URI.extract(new_text).each { |url| new_text.gsub!(url, 'x' * 23) }
+      new_text.gsub!(FetchLinkCardService::URL_PATTERN, 'x' * 23)
       new_text.gsub!(Account::MENTION_RE, '@\2')
     end
   end