Sha256: 52bd3ea179bc568aacfec02deea1b92d0dff66599e953b2c83b9d07172eb7b93

Contents?: true

Size: 1.44 KB

Versions: 24

Compression:

Stored size: 1.44 KB

Contents

require "helper"

class IntegrationTestHelpers < Loofah::TestCase
  context ".strip_tags" do
    context "on safe markup" do
      it "strip out tags" do
        assert_equal "omgwtfbbq!!1!", Loofah::Helpers.strip_tags("<div>omgwtfbbq</div><span>!!1!</span>")
      end
    end

    context "on hack attack" do
      it "strip escape html entities" do
        bad_shit = "&lt;script&gt;alert('evil')&lt;/script&gt;"
        assert_equal bad_shit, Loofah::Helpers.strip_tags(bad_shit)
      end
    end
  end

  context ".sanitize" do
    context "on safe markup" do
      it "render the safe html" do
        html = "<div>omgwtfbbq</div><span>!!1!</span>"
        assert_equal html, Loofah::Helpers.sanitize(html)
      end
    end

    context "on hack attack" do
      it "strip the unsafe tags" do
        assert_equal "alert('evil')<span>w00t</span>", Loofah::Helpers.sanitize("<script>alert('evil')</script><span>w00t</span>")
      end

      it "strips form tags" do
        assert_equal "alert('evil')<span>w00t</span>", Loofah::Helpers.sanitize("<script>alert('evil')</script><form action=\"/foo/bar\" method=\"post\"><input></form><span>w00t</span>")
      end
    end
  end

  context ".sanitize_css" do
    it "removes unsafe css properties" do
      assert_equal "display: block; background-color: blue;", Loofah::Helpers.sanitize_css("display:block;background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg);background-color:blue")
    end
  end
end

Version data entries

24 entries across 24 versions & 9 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/loofah-2.0.3/test/integration/test_helpers.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
abaci-0.3.0 vendor/bundle/gems/loofah-2.0.3/test/integration/test_helpers.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/loofah-2.0.3/test/integration/test_helpers.rb
loofah-2.0.3 test/integration/test_helpers.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/loofah-2.0.2/test/integration/test_helpers.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/loofah-2.0.2/test/integration/test_helpers.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/loofah-2.0.2/test/integration/test_helpers.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/loofah-2.0.2/test/integration/test_helpers.rb
loofah-2.0.2 test/integration/test_helpers.rb