Skip to content
Extraits de code Groupes Projets
Valider e1fcad34 rédigé par Eugen Rochko's avatar Eugen Rochko Validation de GitHub
Parcourir les fichiers

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.
parent 155ba8fd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -33,9 +33,7 @@ class LanguageDetector ...@@ -33,9 +33,7 @@ class LanguageDetector
def simplified_text def simplified_text
text.dup.tap do |new_text| text.dup.tap do |new_text|
URI.extract(new_text).each do |url| new_text.gsub!(FetchLinkCardService::URL_PATTERN, '')
new_text.gsub!(url, '')
end
new_text.gsub!(Account::MENTION_RE, '') new_text.gsub!(Account::MENTION_RE, '')
new_text.gsub!(Tag::HASHTAG_RE, '') new_text.gsub!(Tag::HASHTAG_RE, '')
new_text.gsub!(/\s+/, ' ') new_text.gsub!(/\s+/, ' ')
......
...@@ -24,7 +24,7 @@ class StatusLengthValidator < ActiveModel::Validator ...@@ -24,7 +24,7 @@ class StatusLengthValidator < ActiveModel::Validator
def countable_text(status) def countable_text(status)
status.text.dup.tap do |new_text| 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') new_text.gsub!(Account::MENTION_RE, '@\2')
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter