FIX: skip some checks for CJK locale in TextSentinel (#7322)

This commit is contained in:
Erick Guan
2019-04-05 15:07:49 +02:00
committed by Régis Hanol
parent ca33d091b3
commit 9dd325f805
2 changed files with 16 additions and 0 deletions

View File

@ -69,12 +69,18 @@ class TextSentinel
@text.gsub(symbols_regex, '').size > 0
end
def skipped_locale
%w(zh_CN zh_TW ko ja).freeze
end
def seems_unpretentious?
return true if skipped_locale.include?(SiteSetting.default_locale)
# Don't allow super long words if there is a word length maximum
@opts[:max_word_length].blank? || @text.split(/\s|\/|-|\.|:/).map(&:size).max <= @opts[:max_word_length]
end
def seems_quiet?
return true if skipped_locale.include?(SiteSetting.default_locale)
# We don't allow all upper case content
SiteSetting.allow_uppercase_posts || @text == @text.mb_chars.downcase.to_s || @text != @text.mb_chars.upcase.to_s
end