Sha256: ae2125c373df58ab6e0a54a01dd0b30a58745b0f2d205b6188c9e3f2336b7e3a

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require 'helper'

class TestSlimCodeEscaping < TestSlim
  def test_escaping_evil_method
    source = %q{
p = evil_method
}

    assert_html '<p>&lt;script&gt;do_something_evil();&lt;/script&gt;</p>', source
  end

  def test_render_without_html_safe
    source = %q{
p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
}

    assert_html "<p>&lt;strong&gt;Hello World\n, meet \&quot;Slim\&quot;&lt;/strong&gt;.</p>", source
  end

  def test_render_with_html_safe_false
    source = %q{
p = HtmlUnsafeString.new("<strong>Hello World\\n, meet \\"Slim\\"</strong>.")
}

    assert_html "<p>&lt;strong&gt;Hello World\n, meet \&quot;Slim\&quot;&lt;/strong&gt;.</p>", source, :use_html_safe => true
  end

  def test_render_with_html_safe_true
    source = %q{
p = HtmlSafeString.new("<strong>Hello World\\n, meet \\"Slim\\"</strong>.")
}

    assert_html "<p><strong>Hello World\n, meet \"Slim\"</strong>.</p>", source, :use_html_safe => true
  end

  def test_render_with_disable_escape_false
    source = %q{
= "<p>Hello</p>"
== "<p>World</p>"
}

    assert_html "&lt;p&gt;Hello&lt;/p&gt;<p>World</p>", source
  end

  def test_render_with_disable_escape_true
    source = %q{
= "<p>Hello</p>"
== "<p>World</p>"
}

    assert_html "<p>Hello</p><p>World</p>", source, :disable_escape => true
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slim-1.3.6 test/core/test_code_escaping.rb
slim-1.3.5 test/core/test_code_escaping.rb
slim-1.3.4 test/core/test_code_escaping.rb
slim-1.3.3 test/core/test_code_escaping.rb
slim-1.3.2 test/core/test_code_escaping.rb