Module Haml::Helpers::XssMods
In: lib/haml/helpers/xss_mods.rb

This module overrides Haml helpers to work properly in the context of ActionView. Currently it‘s only used for modifying the helpers to work with Rails’ XSS protection methods.

Methods

Public Class methods

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 8
 8:       def self.included(base)
 9:         %w[html_escape find_and_preserve preserve list_of surround
10:            precede succeed capture_haml haml_concat haml_indent
11:            haml_tag escape_once].each do |name|
12:           base.send(:alias_method, "#{name}_without_haml_xss", name)
13:           base.send(:alias_method, name, "#{name}_with_haml_xss")
14:         end
15:       end

Public Instance methods

Output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 59
59:       def capture_haml_with_haml_xss(*args, &block)
60:         capture_haml_without_haml_xss(*args, &block).html_safe!
61:       end

Output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 81
81:       def escape_once_with_haml_xss(*args)
82:         escape_once_without_haml_xss(*args).html_safe!
83:       end

Output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 26
26:       def find_and_preserve_with_haml_xss(*args, &block)
27:         find_and_preserve_without_haml_xss(*args, &block).html_safe!
28:       end

Input is escaped

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 64
64:       def haml_concat_with_haml_xss(text = "")
65:         haml_concat_without_haml_xss(@_haml_concat_raw ? text : haml_xss_html_escape(text))
66:       end

Output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 69
69:       def haml_indent_with_haml_xss
70:         haml_indent_without_haml_xss.html_safe!
71:       end

Input is escaped, haml_concat‘ed output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 74
74:       def haml_tag_with_haml_xss(name, *rest, &block)
75:         name = haml_xss_html_escape(name.to_s)
76:         rest.unshift(haml_xss_html_escape(rest.shift.to_s)) unless [Symbol, Hash, NilClass].any? {|t| rest.first.is_a? t}
77:         with_raw_haml_concat {haml_tag_without_haml_xss(name, *rest, &block)}
78:       end

Don‘t escape text that‘s already safe, output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 19
19:       def html_escape_with_haml_xss(text)
20:         str = text.to_s
21:         return text if str.html_safe?
22:         html_escape_without_haml_xss(str).html_safe!
23:       end

Output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 36
36:       def list_of_with_haml_xss(*args, &block)
37:         list_of_without_haml_xss(*args, &block).html_safe!
38:       end

Input is escaped, output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 49
49:       def precede_with_haml_xss(str, &block)
50:         precede_without_haml_xss(haml_xss_html_escape(str), &block).html_safe!
51:       end

Output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 31
31:       def preserve_with_haml_xss(*args, &block)
32:         preserve_without_haml_xss(*args, &block).html_safe!
33:       end

Input is escaped, output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 54
54:       def succeed_with_haml_xss(str, &block)
55:         succeed_without_haml_xss(haml_xss_html_escape(str), &block).html_safe!
56:       end

Input is escaped, output is always HTML safe

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 41
41:       def surround_with_haml_xss(front, back = front, &block)
42:         surround_without_haml_xss(
43:           haml_xss_html_escape(front),
44:           haml_xss_html_escape(back),
45:           &block).html_safe!
46:       end

Private Instance methods

Escapes the HTML in the text if and only if Rails XSS protection is enabled and the `:escape_html` option is set.

[Source]

    # File lib/haml/helpers/xss_mods.rb, line 89
89:       def haml_xss_html_escape(text)
90:         return text unless Haml::Util.rails_xss_safe? && haml_buffer.options[:escape_html]
91:         html_escape(text)
92:       end

[Validate]