Sha256: 0e209ce56402ecaabf642cae2d22edb16b56a92b5cd01ee411e2a5bb9ae2fc9e

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

require 'helper'

class TestSkimCodeEscaping < TestSkim
  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_unsafe
    source = %q{
p = "<strong>Hello World\\n, meet \\"Skim\\"</strong>."
}

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

  def test_render_safe
    source = %q{
p = @safe("<strong>Hello World\\n, meet \\"Skim\\"</strong>.")
}

    assert_html "<p><strong>Hello World\n, meet \"Skim\"</strong>.</p>", source
  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

  def test_explicit_escape
    source = %q{
= @escape "Crate & Barrel"
}

    assert_html "Crate &amp; Barrel", source
  end

  def test_explicit_safe
    source = %q{
= @safe "Crate & Barrel"
}

    assert_html "Crate & Barrel", source
  end

  def test_user_defined_escape
    source = %q{
= "Crate & Barrel"
}

    assert_html "CRATE & BARREL", source, :context => "{escape: function (value) { return value.toUpperCase(); }}"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
skim-0.8.6 test/test_code_escaping.rb
skim-0.8.5 test/test_code_escaping.rb
skim-0.8.4 test/test_code_escaping.rb
skim-0.8.3 test/test_code_escaping.rb
skim-0.8.2 test/test_code_escaping.rb
skim-0.8.1 test/test_code_escaping.rb
skim-0.8.0 test/test_code_escaping.rb