Permalink
Browse files

number_to_phone always return safe

  • Loading branch information...
1 parent 2f9e880 commit ea7db8ebc11bedc2d98dac03df96bd73f6bfcf6b @spastorino spastorino committed Oct 17, 2010
@@ -51,12 +51,9 @@ def number_to_phone(number, options = {})
begin
Float(number)
- is_number_html_safe = true
rescue ArgumentError, TypeError
if options[:raise]
raise InvalidNumberError, number
- else
- is_number_html_safe = number.to_s.html_safe?
end
end
@@ -76,7 +73,7 @@ def number_to_phone(number, options = {})
number.starts_with?('-') ? number.slice!(1..-1) : number
end
str << " x #{extension}" unless extension.blank?
- is_number_html_safe ? str.html_safe : str
+ html_escape(str)
end
# Formats a +number+ into a currency string (e.g., $13.65). You can customize the format
@@ -289,7 +289,8 @@ def test_number_helpers_outputs_are_html_safe
assert number_to_percentage("asdf".html_safe).html_safe?
assert number_to_phone(1).html_safe?
- assert !number_to_phone("<script></script>").html_safe?
+ assert_equal "&lt;script&gt;&lt;/script&gt;", number_to_phone("<script></script>")
+ assert number_to_phone("<script></script>").html_safe?
assert number_to_phone("asdf".html_safe).html_safe?
assert number_with_delimiter(1).html_safe?

0 comments on commit ea7db8e

Please sign in to comment.