mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:41:25 +08:00
FEATURE: Improve errors when title is invalid (#11149)
It used to simply say "title is invalid" without giving any hint what the problem could be. This commit adds different errors messages for all caps titles, low entropy titles or titles with very long words.
This commit is contained in:
@ -54,12 +54,6 @@ class TextSentinel
|
||||
seems_quiet?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def symbols_regex
|
||||
/[\ -\/\[-\`\:-\@\{-\~]/m
|
||||
end
|
||||
|
||||
def seems_meaningful?
|
||||
# Minimum entropy if entropy check required
|
||||
@opts[:min_entropy].blank? || (entropy >= @opts[:min_entropy])
|
||||
@ -71,10 +65,6 @@ 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
|
||||
@ -87,4 +77,14 @@ class TextSentinel
|
||||
SiteSetting.allow_uppercase_posts || @text == @text.mb_chars.downcase.to_s || @text != @text.mb_chars.upcase.to_s
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def symbols_regex
|
||||
/[\ -\/\[-\`\:-\@\{-\~]/m
|
||||
end
|
||||
|
||||
def skipped_locale
|
||||
%w(zh_CN zh_TW ko ja).freeze
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user