From 26698fb91d88dca0f860adcb80528d8d3f0f6285 Mon Sep 17 00:00:00 2001 From: Sean Walbran Date: Wed, 5 Feb 2014 17:19:51 -0600 Subject: fix interplay of humanize and html_escape --- activesupport/lib/active_support/inflector/methods.rb | 2 +- activesupport/test/core_ext/string_ext_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index cdee4c2ca5..b642d87d76 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -117,7 +117,7 @@ module ActiveSupport result.gsub!(/([a-z\d]*)/i) { |match| "#{inflections.acronyms[match] || match.downcase}" } - result.gsub!(/^\w/) { $&.upcase } if options.fetch(:capitalize, true) + result.gsub!(/^\w/) { |match| match.upcase } if options.fetch(:capitalize, true) result end diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index d4f8ba8cdd..072b970a2d 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -161,6 +161,10 @@ class StringInflectionsTest < ActiveSupport::TestCase end end + def test_humanize_with_html_escape + assert_equal 'Hello', ERB::Util.html_escape("hello").humanize + end + def test_ord assert_equal 97, 'a'.ord assert_equal 97, 'abc'.ord -- cgit v1.2.3