Sha256: 80c726dc038e483f6a13a2d7c00290a2ffcefd3adc72d3bf8e6826fed179a399

Contents?: true

Size: 1.29 KB

Versions: 55

Compression:

Stored size: 1.29 KB

Contents

require 'helper'

class TestSlimHtmlEscaping < TestSlim
  def test_html_will_not_be_escaped
    source = %q{
p <Hello> World, meet "Slim".
}

    assert_html '<p><Hello> World, meet "Slim".</p>', source
  end

  def test_html_with_newline_will_not_be_escaped
    source = %q{
p
  |
    <Hello> World,
     meet "Slim".
}

    assert_html "<p><Hello> World,\n meet \"Slim\".</p>", source
  end

  def test_html_with_escaped_interpolation
    source = %q{
- x = '"'
- content = '<x>'
p class="#{x}" test #{content}
}

    assert_html '<p class="&quot;">test &lt;x&gt;</p>', source
  end

  def test_html_nested_escaping
    source = %q{
= hello_world do
  | escaped &
}
    assert_html 'Hello World from @env escaped &amp; Hello World from @env', source
  end

  def test_html_quoted_attr_escape
    source = %q{
p id="&" class=="&amp;"
}

    assert_html '<p class="&amp;" id="&amp;"></p>', source
  end

  def test_html_quoted_attr_escape_with_interpolation
    source = %q{
p id="&#{'"'}" class=="&amp;#{'"'}"
p id="&#{{'"'}}" class=="&amp;#{{'"'}}"
}

    assert_html '<p class="&amp;&quot;" id="&amp;&quot;"></p><p class="&amp;"" id="&amp;""></p>', source
  end

  def test_html_ruby_attr_escape
    source = %q{
p id=('&'.to_s) class==('&amp;'.to_s)
}

    assert_html '<p class="&amp;" id="&amp;"></p>', source
  end
end

Version data entries

55 entries across 55 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/slim-4.1.0/test/core/test_html_escaping.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/slim-4.1.0/test/core/test_html_escaping.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/slim-4.1.0/test/core/test_html_escaping.rb
slim-5.2.1 test/core/test_html_escaping.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/slim-4.1.0/test/core/test_html_escaping.rb
slim-5.2.0 test/core/test_html_escaping.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/slim-4.1.0/test/core/test_html_escaping.rb
slim-5.1.1 test/core/test_html_escaping.rb
slim-5.1.0 test/core/test_html_escaping.rb
slim-5.0.0 test/core/test_html_escaping.rb
slim-4.1.0 test/core/test_html_escaping.rb
slim-4.0.1 test/core/test_html_escaping.rb
slim-4.0.0 test/core/test_html_escaping.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/slim-3.0.7/test/core/test_html_escaping.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/slim-3.0.7/test/core/test_html_escaping.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/slim-3.0.7/test/core/test_html_escaping.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/slim-3.0.7/test/core/test_html_escaping.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/slim-3.0.7/test/core/test_html_escaping.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/slim-3.0.7/test/core/test_html_escaping.rb
slim-3.0.9 test/core/test_html_escaping.rb