Sha256: fa73c0157e46d62b50b473963e177f7358d89fd96f522c475e84234cb18d153d

Contents?: true

Size: 958 Bytes

Versions: 19

Compression:

Stored size: 958 Bytes

Contents

require File.expand_path('../../unit_test_helper', __FILE__)

class SanitizeTest < Test::Unit::TestCase

  def test_trasform
    result = auto_html("<script>alert(0)</script>") { sanitize }
    assert_equal "", result
  end

  def test_trasform2
    result = auto_html("<div>test</div>") { sanitize }
    assert_equal "<div>test</div>", result
  end

  def test_trasform3
    result = auto_html("<div>test</div>") { sanitize :tags => %w(div) }
    assert_equal "<div>test</div>", result
  end

  def test_trasform4
    result = auto_html("<div>test</div>") { sanitize :tags => %w(p) }
    assert_equal "test", result
  end

  def test_trasform5
    result = auto_html("<a rel='nofollow'>test</div>") { sanitize :tags => %w(a), :attributes => %w(href)}
    assert_equal "<a>test", result 
    #
    # from Rails doc:
    #
    #   Please note that sanitizing user-provided text does not 
    #   guarantee that the resulting markup is valid.
    #
  end

end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
auto_html-1.6.4 test/unit/filters/sanitize_test.rb
auto_html-1.6.3 test/unit/filters/sanitize_test.rb
auto_html-1.5.1.1 test/unit/filters/sanitize_test.rb
auto_html-1.6.2 test/unit/filters/sanitize_test.rb
auto_html-1.6.1 test/unit/filters/sanitize_test.rb
auto_html-1.6.0 test/unit/filters/sanitize_test.rb
auto_html-1.5.3 test/unit/filters/sanitize_test.rb
auto_html-1.5.2 test/unit/filters/sanitize_test.rb
auto_html-1.5.1 test/unit/filters/sanitize_test.rb
auto_html-1.5.0 test/unit/filters/sanitize_test.rb
marcosinger-auto_html-1.3.6 test/unit/filters/sanitize_test.rb
auto_html-1.4.2 test/unit/filters/sanitize_test.rb
auto_html-1.4.1 test/unit/filters/sanitize_test.rb
auto_html-1.4.0 test/unit/filters/sanitize_test.rb
auto_html-1.3.7 test/unit/filters/sanitize_test.rb
marcosinger-auto_html-1.3.5 test/unit/filters/sanitize_test.rb
marcosinger-auto_html-1.3.4 test/unit/filters/sanitize_test.rb
auto_html-1.3.6 test/unit/filters/sanitize_test.rb
auto_html-1.3.5 test/unit/filters/sanitize_test.rb