aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-07-20 02:38:26 -0700
committerXavier Noria <fxn@hashref.com>2011-07-20 02:38:26 -0700
commitaf561901a0e4fb5585fd25a1cb3e76b6761c1e91 (patch)
treed00c1ea73cfc9044c7b266560f72228611424e8f /activesupport
parentb8a4e9fc6d4b7020d1fdeaa39e935330c5dadccd (diff)
parent0c58f39c2c7ff590e854772e41f6d10117a51c53 (diff)
downloadrails-af561901a0e4fb5585fd25a1cb3e76b6761c1e91.tar.gz
rails-af561901a0e4fb5585fd25a1cb3e76b6761c1e91.tar.bz2
rails-af561901a0e4fb5585fd25a1cb3e76b6761c1e91.zip
Merge pull request #2146 from dmathieu/blank_binary_encoding
fix String#blank? on binary strings
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/object/blank.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb
index d060ac04d8..5556546822 100644
--- a/activesupport/lib/active_support/core_ext/object/blank.rb
+++ b/activesupport/lib/active_support/core_ext/object/blank.rb
@@ -99,7 +99,12 @@ class String
# " something here ".blank? # => false
#
def blank?
- self !~ NON_WHITESPACE_REGEXP
+ # 1.8 does not takes [:space:] properly
+ if encoding_aware?
+ self !~ /[^[:space:]]/
+ else
+ self !~ NON_WHITESPACE_REGEXP
+ end
end
end