From 2f60bb3327453ef214b78ed99c7e7c034774bb81 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 18 Sep 2007 11:56:04 +0000 Subject: ERB::Util#html_escape creates fewer objects git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7513 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/base.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/lib/action_view/base.rb') 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 = { '&' => '&', '"' => '"', '>' => '>', '<' => '<' } + + def html_escape(s) + s.to_s.gsub(/[&\"><]/) { |special| HTML_ESCAPE[special] } + end + end +end + module ActionView #:nodoc: class ActionViewError < StandardError #:nodoc: end -- cgit v1.2.3