0
@@ -20,6 +20,9 @@ module Haml
0
# Designates script, the result of which is output.
0
+ # Designates script that is always be HTML-escaped.
0
# Designates script, the result of which is flattened and output.
0
@@ -47,6 +50,7 @@ module Haml
0
@@ -197,9 +201,16 @@ END
0
when DIV_CLASS, DIV_ID; render_div(text)
0
when ELEMENT; render_tag(text)
0
when COMMENT; render_comment(text)
0
+ return push_script(text[2..-1].strip, false, nil, false, true) if text[1] == SCRIPT
0
return push_script(unescape_interpolation(text[2..-1].strip), false) if text[1] == SCRIPT
0
- push_script(text[1..-1], false)
0
+ if options[:escape_html]
0
+ push_script(text[1..-1], false, nil, false, true)
0
+ push_script(text[1..-1], false)
0
when FLAT_SCRIPT; push_flat_script(text[1..-1])
0
return start_haml_comment if text[1] == SILENT_COMMENT
0
when FILTER; start_filtered(text[1..-1].downcase)
0
return render_doctype(text) if text[0...3] == '!!!'
0
+ return push_script(text[2..-1].strip, false) if text[1] == SCRIPT
0
when ESCAPE; push_plain text[1..-1]
0
@@ -319,13 +331,13 @@ END
0
# If <tt>preserve_script</tt> is true, Haml::Helpers#find_and_flatten is run on
0
# the result before it is added to <tt>@buffer</tt>
0
- def push_script(text, preserve_script, close_tag = nil, preserve_tag = false
)
0
+ def push_script(text, preserve_script, close_tag = nil, preserve_tag = false
, escape_html = false)
0
return if options[:suppress_eval]
0
push_silent "haml_temp = #{text}"
0
- out = "haml_temp = _hamlout.push_script(haml_temp, #{preserve_script.inspect}, #{close_tag.inspect}, #{preserve_tag.inspect}
);"
0
+ out = "haml_temp = _hamlout.push_script(haml_temp, #{preserve_script.inspect}, #{close_tag.inspect}, #{preserve_tag.inspect}
, #{escape_html.inspect});"
0
push_and_tabulate([:loud, out])
0
object_ref, rest = balance(rest, ?[, ?]) if rest[0] == ?[
0
- action, value = rest.scan(/([=\/\~
]?)?(.*)?/)[0]
0
+ action, value = rest.scan(/([=\/\~
&!]?)?(.*)?/)[0]
0
value = value.to_s.strip
0
[tag_name, attributes, attributes_hash, object_ref, action, value]
0
@@ -517,13 +529,20 @@ END
0
value = unescape_interpolation(value[1..-1].strip) if value[0] == ?=
0
+ value = value[1..-1].strip
0
if parse && @options[:suppress_eval]
0
+ escape_html = (action == '&' || (action != '!' && @options[:escape_html]))
0
object_ref = "nil" if object_ref.nil? || @options[:suppress_eval]
0
static_attributes = parse_static_hash(attributes_hash) # Try pre-compiling a static attributes hash
0
- push_script(value, preserve_script, tag_name, preserve_tag
)
0
+ push_script(value, preserve_script, tag_name, preserve_tag
, escape_html)
0
raise SyntaxError.new("Unbalanced brackets.")
0
# Counts the tabulation of a line.
0
def count_soft_tabs(line)
Comments
No one has commented yet.