Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_xss/string_ext.rb

Instance Method Summary collapse

Instance Method Details

#add_with_safety(other) ⇒ Object Also known as: +



25
26
27
28
29
30
31
32
# File 'lib/rails_xss/string_ext.rb', line 25

def add_with_safety(other)
  result = add_without_safety(other)
  if html_safe? && also_html_safe?(other)
    result.html_safe!
  else
    result
  end
end

#concat_with_safety(other_or_fixnum) ⇒ Object Also known as: <<



36
37
38
39
40
41
42
# File 'lib/rails_xss/string_ext.rb', line 36

def concat_with_safety(other_or_fixnum)
  result = concat_without_safety(other_or_fixnum)
  unless html_safe? && also_html_safe?(other_or_fixnum)
    remove_instance_variable(:@_rails_html_safe) if defined?(@_rails_html_safe)
  end
  result
end

#html_safe!Object



19
20
21
22
23
# File 'lib/rails_xss/string_ext.rb', line 19

def html_safe!
  ActiveSupport::Deprecation.warn("Use html_safe with your strings instead of html_safe! See http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/ for the full story.", caller)
  @_rails_html_safe = true
  self
end

#html_safe?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rails_xss/string_ext.rb', line 15

def html_safe?
  defined?(@_rails_html_safe)
end