Permalink
Browse files

Merge pull request #5174 from nashby/safe-concat

use content_tag instead of strings
  • Loading branch information...
2 parents eecb086 + 2bc879a commit cbe74cf024f550d08c8b7f8ec0e5e5f90a1772f6 @josevalim josevalim committed Feb 25, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 actionpack/lib/action_view/helpers/tags/base.rb
View
7 actionpack/lib/action_view/helpers/tags/base.rb
@@ -133,13 +133,14 @@ def select_content_tag(option_tags, options, html_options)
def add_options(option_tags, options, value = nil)
if options[:include_blank]
- option_tags = "<option value=\"\">#{ERB::Util.html_escape(options[:include_blank]) if options[:include_blank].kind_of?(String)}</option>\n" + option_tags
+ include_blank = options[:include_blank] if options[:include_blank].kind_of?(String)
+ option_tags = content_tag(:option, include_blank, :value => '').safe_concat("\n").safe_concat(option_tags)
end
if value.blank? && options[:prompt]
prompt = options[:prompt].kind_of?(String) ? options[:prompt] : I18n.translate('helpers.select.prompt', :default => 'Please select')
- option_tags = "<option value=\"\">#{ERB::Util.html_escape(prompt)}</option>\n" + option_tags
+ option_tags = content_tag(:option, prompt, :value => '').safe_concat("\n").safe_concat(option_tags)
end
- option_tags.html_safe
+ option_tags
end
end
end

0 comments on commit cbe74cf

Please sign in to comment.