Skip to content

Commit

Permalink
Check for block expressions here
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino authored and henare committed Jan 14, 2013
1 parent b63c3e5 commit 6c9b5dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rails_xss/erubis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ def add_text(src, text)
src << "@output_buffer.safe_concat('" << escape_text(text) << "');"
end

BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/

def add_expr_literal(src, code)
if code =~ /\s*raw\s+(.*)/
if code =~ BLOCK_EXPR
src << "@output_buffer.safe_concat((" << $1 << ").to_s);"
else
src << '@output_buffer << ((' << code << ').to_s);'
Expand Down

0 comments on commit 6c9b5dc

Please sign in to comment.