0
0
Fork 0

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.
This commit is contained in:
Eugen Rochko 2017-07-31 05:06:20 +02:00 committed by GitHub
parent 155ba8fd3a
commit e1fcad34a9
2 changed files with 2 additions and 4 deletions

View file

@ -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