提交 e711d8fa 编写于 作者: J Jeremy Kemper

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
上级 cb5b8a7f
......@@ -94,7 +94,7 @@ def cdata_section(content)
# escape_once("<< Accept & Checkout")
# # => "<< Accept & 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 @@ def tag_options(options)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册