Skip to content
Browse files

reverting decoupling of NumberHelper from safe_join and adding tests …

…for escaping of delimiters and separators
  • Loading branch information...
1 parent 476ef2d commit 2c423b3f3f0d489b0e9943b69f5b25d97006ca74 @amutz amutz committed May 16, 2012
View
2 actionpack/lib/action_view/helpers/number_helper.rb
@@ -254,7 +254,7 @@ def number_with_delimiter(number, options = {})
parts = number.to_s.to_str.split('.')
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
- parts.join(options[:separator]).html_safe
+ safe_join(parts, options[:separator])
end
# Formats a +number+ with the specified level of
View
2 actionpack/test/template/number_helper_test.rb
@@ -78,6 +78,8 @@ def test_number_with_delimiter_with_options_hash
assert_equal '12,345,678-05', number_with_delimiter(12345678.05, :separator => '-')
assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :separator => ',', :delimiter => '.')
assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :delimiter => '.', :separator => ',')
+ assert_equal '1&lt;script&gt;&lt;/script&gt;01', number_with_delimiter(1.01, :separator => "<script></script>")
+ assert_equal '1&lt;script&gt;&lt;/script&gt;000', number_with_delimiter(1000, :delimiter => "<script></script>")
end
def test_number_with_precision
View
1 activesupport/lib/active_support/testing/performance.rb
@@ -196,6 +196,7 @@ def self.[](name)
class Base
include ActionView::Helpers::NumberHelper
+ include ActionView::Helpers::OutputSafetyHelper
attr_reader :total

0 comments on commit 2c423b3

Please sign in to comment.
Something went wrong with that request. Please try again.