Permalink
Browse files

trust generated HTML, and define html_safe! for gem >= 2.3 just in ca…

…se by now
  • Loading branch information...
1 parent 8fcf234 commit 326829633cb820cad77be5400939b9a853c42337 @fxn fxn committed Oct 10, 2009
Showing with 10 additions and 4 deletions.
  1. +10 −4 railties/guides/rails_guides/generator.rb
@@ -1,5 +1,11 @@
require 'set'
+class String
+ def html_safe!
+ self
+ end unless "post 9415935902f120a9bac0bfce7129725a0db38ed3".respond_to?(:html_safe!)
+end
+
module RailsGuides
class Generator
attr_reader :output, :view_path, :view, :guides_dir
@@ -55,7 +61,7 @@ def generate_guide(guide)
body = set_header_section(body, @view)
body = set_index(body, @view)
- result = view.render(:layout => 'layout', :text => textile(body))
+ result = view.render(:layout => 'layout', :text => textile(body).html_safe!)
f.write result
warn_about_broken_links(result) if ENV.key?("WARN_BROKEN_LINKS")
end
@@ -71,8 +77,8 @@ def set_header_section(body, view)
header = textile(header)
- view.content_for(:page_title) { page_title }
- view.content_for(:header_section) { header }
+ view.content_for(:page_title) { page_title.html_safe! }
+ view.content_for(:header_section) { header.html_safe! }
new_body
end
@@ -103,7 +109,7 @@ def set_index(body, view)
index << '</ol>'
index << '</div>'
- view.content_for(:index_section) { index }
+ view.content_for(:index_section) { index.html_safe! }
i.result
end

0 comments on commit 3268296

Please sign in to comment.