aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-24 05:43:59 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-24 05:43:59 +0000
commite711d8fade2a47e4a709fa3eb4b8dd7af6f6ac08 (patch)
treee372b3807c822d37b2bd24495242bd16459379d6
parentcb5b8a7f055966c1f3e2d65d09c1b914e82d2c39 (diff)
downloadrails-e711d8fade2a47e4a709fa3eb4b8dd7af6f6ac08.tar.gz
rails-e711d8fade2a47e4a709fa3eb4b8dd7af6f6ac08.tar.bz2
rails-e711d8fade2a47e4a709fa3eb4b8dd7af6f6ac08.zip
escape_once uses negative lookahead to avoid double-escaping instead of a second gsub
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7606 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb7
1 files changed, 1 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index f222e43adc..963f494760 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -94,7 +94,7 @@ module ActionView
# escape_once("&lt;&lt; Accept & Checkout")
# # => "&lt;&lt; Accept &amp; Checkout"
def escape_once(html)
- fix_double_escape(html_escape(html.to_s))
+ html.to_s.gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |special| ERB::Util::HTML_ESCAPE[special] }
end
private
@@ -116,11 +116,6 @@ module ActionView
end
end
- # Fix double-escaped entities, such as &amp;amp;, &amp;#123;, etc.
- def fix_double_escape(escaped)
- escaped.gsub(/&amp;([a-z]+|(#\d+));/i) { "&#{$1};" }
- end
-
def block_is_within_action_view?(block)
eval("defined? _erbout", block.binding)
end