diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-01-23 05:27:25 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-01-23 05:27:25 +0000 |
commit | a44cee2549e04e6e586f0f9432d98bb2dd4e3625 (patch) | |
tree | 1f1f1f37b7bb4a9622fa8407caeef937e0149fd1 /activesupport/lib/active_support | |
parent | 1bdb14bdd3cad4ae8850040d6d82c3c3c624f224 (diff) | |
download | rails-a44cee2549e04e6e586f0f9432d98bb2dd4e3625.tar.gz rails-a44cee2549e04e6e586f0f9432d98bb2dd4e3625.tar.bz2 rails-a44cee2549e04e6e586f0f9432d98bb2dd4e3625.zip |
ActiveSupport::Multibyte::Handlers::UTF8Handler should raise when a range and an integer are passed in (just like the native implementation). Closes #7176 [Rich Collins]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6021 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb b/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb index a34701b1af..0d13cebf5c 100644 --- a/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb +++ b/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb @@ -168,8 +168,12 @@ module ActiveSupport::Multibyte::Handlers # Implements Unicode-aware slice with codepoints. Slicing on one point returns the codepoints for that # character. def slice(str, *args) - if (args.size == 2 && args.first.is_a?(Range)) - raise TypeError, 'cannot convert Range into Integer' # Do as if we were native + if args.size > 2 + raise ArgumentError, "wrong number of arguments (#{args.size} for 1)" # Do as if we were native + elsif (args.size == 2 && !(args.first.is_a?(Numeric) || args.first.is_a?(Regexp))) + raise TypeError, "cannot convert #{args.first.class} into Integer" # Do as if we were native + elsif (args.size == 2 && !args[1].is_a?(Numeric)) + raise TypeError, "cannot convert #{args[1].class} into Integer" # Do as if we were native elsif args[0].kind_of? Range cps = u_unpack(str).slice(*args) cps.nil? ? nil : cps.pack('U*') |