Ver a proveniência

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.
master
Eugen Rochko há 6 anos
committed by GitHub
ascendente
cometimento
e1fcad34a9
2 ficheiros alterados com 2 adições e 4 eliminações
  1. +1
    -3
      app/lib/language_detector.rb
  2. +1
    -1
      app/validators/status_length_validator.rb

+ 1
- 3
app/lib/language_detector.rb Ver ficheiro

@@ -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+/, ' ')


+ 1
- 1
app/validators/status_length_validator.rb Ver ficheiro

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


Carregando…
Cancelar
Guardar