Sha256: 6ed412ac5df087d9c8bb1750a42e4c47976107f893b5611766b36eb8fdff1270

Contents?: true

Size: 1.29 KB

Versions: 107

Compression:

Stored size: 1.29 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;&#47;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;&#47;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;&#47;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;&#47;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

107 entries across 62 versions & 3 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.7.5 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.7.4 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.7.4 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.7.3 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.7.3 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.7.2 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.7.2 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.7.1 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.7.1 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.7.0 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.7.0 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.6.9 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.6.9 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.6.8 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.6.8 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.6.7 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.6.7 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb
classiccms-0.6.6 vendor/bundle/gems/slim-1.2.1/test/slim/test_code_escaping.rb
classiccms-0.6.6 vendor/bundle/gems/slim-1.2.0/test/slim/test_code_escaping.rb