mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Unicode aware text sentinel (#4301)
* FIX: Handle unicode text on Text Sentinel Uses active_support to properly handle unicode text * Adds test cases to unicode Text Sentinel
This commit is contained in:
committed by
Robin Ward
parent
166d753bd3
commit
5915929166
@@ -1,3 +1,7 @@
|
||||
# Whe use ActiveSupport mb_chars from here to properly support non ascii downcase
|
||||
# TODO remove when ruby 2.4 lands
|
||||
require 'active_support/core_ext/string/multibyte'
|
||||
|
||||
#
|
||||
# Given a string, tell us whether or not is acceptable.
|
||||
#
|
||||
@@ -72,8 +76,8 @@ class TextSentinel
|
||||
|
||||
|
||||
def seems_quiet?
|
||||
# We don't allow all upper case content in english
|
||||
SiteSetting.allow_uppercase_posts || not((@text =~ /[A-Z]+/) && !(@text =~ /[^[:ascii:]]/) && (@text == @text.upcase))
|
||||
# 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
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user