Sha256: e4564dcd083afef7f43144ce81c2b14d1cf2c953220c0cd3f7f91ca77fb3d263

Contents?: true

Size: 807 Bytes

Versions: 71

Compression:

Stored size: 807 Bytes

Contents

require 'test_helper'

class SafeRenderTest < Redcarpet::TestCase
  def setup
    @renderer = Redcarpet::Render::Safe
  end

  def test_safe_links_only_is_enabled_by_default
    markdown = "[foo](javascript:alert('foo'))"
    output   = render(markdown)

    assert_not_match %r{a href}, output
  end

  def test_escape_html_is_enabled_by_default
    markdown = "<p>Hello world!</p>"
    output   = render(markdown)

    assert_match %r{&lt;}, output
  end

  def test_html_escaping_in_code_blocks
    markdown = "~~~\n<p>Hello!</p>\n~~~"
    output   = render(markdown)

    assert_match %r{&lt;p&gt;}, output
  end

  def test_lang_class_is_removed
    markdown = "~~~ruby\nclass Foo; end\n~~~"
    output   = render(markdown, with: [:fenced_code_blocks])

    assert_not_match %r{ruby}, output
  end
end

Version data entries

71 entries across 56 versions & 9 rubygems

Version Path
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/redcarpet-3.3.4/test/safe_render_test.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/redcarpet-3.5.0/test/safe_render_test.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/redcarpet-3.5.1/test/safe_render_test.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/redcarpet-3.5.0/test/safe_render_test.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/redcarpet-3.5.0/test/safe_render_test.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/redcarpet-3.5.0/test/safe_render_test.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/redcarpet-3.5.0/test/safe_render_test.rb