aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-18 11:56:04 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-18 11:56:04 +0000
commit2f60bb3327453ef214b78ed99c7e7c034774bb81 (patch)
tree201afb2c19bc05402f79707cbc7a1cac6af1cb2e /actionpack
parent8fd263cd4ec740bda56b6f4c0d3e2ddd91f05722 (diff)
downloadrails-2f60bb3327453ef214b78ed99c7e7c034774bb81.tar.gz
rails-2f60bb3327453ef214b78ed99c7e7c034774bb81.tar.bz2
rails-2f60bb3327453ef214b78ed99c7e7c034774bb81.zip
ERB::Util#html_escape creates fewer objects
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7513 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/base.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index a8e6655bd6..14c42ce855 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -1,5 +1,15 @@
require 'erb'
+class ERB
+ module Util
+ HTML_ESCAPE = { '&' => '&amp;', '"' => '&quot;', '>' => '&gt;', '<' => '&lt;' }
+
+ def html_escape(s)
+ s.to_s.gsub(/[&\"><]/) { |special| HTML_ESCAPE[special] }
+ end
+ end
+end
+
module ActionView #:nodoc:
class ActionViewError < StandardError #:nodoc:
end