diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-13 16:11:40 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-13 16:11:40 -0300 |
commit | 2b84eea9c0ccf910111c447a04ed968f2e8a74d2 (patch) | |
tree | 46c24d584eca1013e6c900a3c02c1b8bd70f33b5 /activesupport | |
parent | 0626543f6d4c45250da15f41d715754c3be5a67e (diff) | |
parent | 3703a8ae9b74ef76551a1e95d4d31aa9fce72eb3 (diff) | |
download | rails-2b84eea9c0ccf910111c447a04ed968f2e8a74d2.tar.gz rails-2b84eea9c0ccf910111c447a04ed968f2e8a74d2.tar.bz2 rails-2b84eea9c0ccf910111c447a04ed968f2e8a74d2.zip |
Merge pull request #15072 from mjtko/fix/issue-15064
[Fixes #15064] Calling number_to_delimited on a ActiveSupport::SafeBuffer results in mangled output
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG.md | 9 | ||||
-rw-r--r-- | activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb | 4 | ||||
-rw-r--r-- | activesupport/test/number_helper_test.rb | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 8d16898c80..68b327e0ad 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,12 @@ +* Fixed an issue when using + `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to + convert a value that is an `ActiveSupport::SafeBuffer` introduced + in 2da9d67. + + For more info see #15064. + + *Mark J. Titorenko* + * `TimeZone#parse` defaults the day of the month to '1' if any other date components are specified. This is more consistent with the behavior of `Time#parse`. diff --git a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb b/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb index 6405afc9a6..d85cc086d7 100644 --- a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb @@ -13,7 +13,9 @@ module ActiveSupport def parts left, right = number.to_s.split('.') - left.gsub!(DELIMITED_REGEX) { "#{$1}#{options[:delimiter]}" } + left.gsub!(DELIMITED_REGEX) do |digit_to_delimit| + "#{digit_to_delimit}#{options[:delimiter]}" + end [left, right].compact end end diff --git a/activesupport/test/number_helper_test.rb b/activesupport/test/number_helper_test.rb index 9bdb92024e..a7a0ae02e7 100644 --- a/activesupport/test/number_helper_test.rb +++ b/activesupport/test/number_helper_test.rb @@ -1,5 +1,6 @@ require 'abstract_unit' require 'active_support/number_helper' +require 'active_support/core_ext/string/output_safety' module ActiveSupport module NumberHelper @@ -97,6 +98,7 @@ module ActiveSupport assert_equal("123,456,789.78901", number_helper.number_to_delimited(123456789.78901)) assert_equal("0.78901", number_helper.number_to_delimited(0.78901)) assert_equal("123,456.78", number_helper.number_to_delimited("123456.78")) + assert_equal("123,456.78", number_helper.number_to_delimited("123456.78".html_safe)) end end |