From b235af702a086dd06fa9849ee47942e8ce82090d Mon Sep 17 00:00:00 2001 From: Gabriel Mansour Date: Sat, 30 Jan 2010 12:38:33 -0500 Subject: Fix pluralization for numbers formatted like '1.00' Signed-off-by: Jeremy Kemper --- actionpack/lib/action_view/helpers/text_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers/text_helper.rb') diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 412e0c82cb..b63617322f 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -187,7 +187,7 @@ module ActionView # pluralize(0, 'person') # # => 0 people def pluralize(count, singular, plural = nil) - "#{count || 0} " + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize)) + "#{count || 0} " + ((count == 1 || count =~ /^1(\.0+)?$/) ? singular : (plural || singular.pluralize)) end # Wraps the +text+ into lines no longer than +line_width+ width. This method -- cgit v1.2.3 From 325fa58ef585b4303a41270e231918f298ee30bd Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 12 Feb 2010 16:38:24 -0800 Subject: Safely concat the ending tag to simple_format or it will be escaped --- actionpack/lib/action_view/helpers/text_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers/text_helper.rb') diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index b63617322f..d84515d5b5 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -332,7 +332,7 @@ module ActionView text.gsub!(/\n\n+/, "

\n\n#{start_tag}") # 2+ newline -> paragraph text.gsub!(/([^\n]\n)(?=[^\n])/, '\1
') # 1 newline -> br text.insert 0, start_tag - text << "

" + text.safe_concat("

") end # Turns all URLs and e-mail addresses into clickable links. The :link option -- cgit v1.2.3 From d68f8ba5c303556ecb8625dd146184d68b704e83 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 12 Feb 2010 17:24:04 -0800 Subject: simple_format returns a safe buffer escaping unsafe input [Santiago Pastorino] --- actionpack/lib/action_view/helpers/text_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers/text_helper.rb') diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index d84515d5b5..b19a9754f4 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -327,7 +327,7 @@ module ActionView # # => "

Look ma! A class!

" def simple_format(text, html_options={}) start_tag = tag('p', html_options, true) - text = text.to_s.dup + text = h(text) text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n text.gsub!(/\n\n+/, "

\n\n#{start_tag}") # 2+ newline -> paragraph text.gsub!(/([^\n]\n)(?=[^\n])/, '\1
') # 1 newline -> br -- cgit v1.2.3