Sha256: 01c2fbdb13cf53a3c33b0913801a131722921bbf681e2f2525d22976a7e0f00c

Contents?: true

Size: 858 Bytes

Versions: 26

Compression:

Stored size: 858 Bytes

Contents

# Run from your Rails main directory
require 'test/test_helper'

class TestHaml < Test::Unit::TestCase
  def setup
    @base = ActionView::Base.new
  end

  def assert_haml_renders(expected, input)
    actual = Haml::Engine.new(input).to_html(@base)
    assert_equal expected, actual
  end

  def test_haml_engine
    assert_haml_renders <<OUT, <<IN
A & B
C &amp; D
E &amp; F
G & H
I &amp; J
OUT
A & B
= "C & D"
= h("E & F")
= "G & H".mark_as_xss_protected
= "I & J".to_s_xss_protected
IN
  end
  
  def test_attribute_escaping_in_haml
    @base.instance_eval {
      @foo = "A < & > ' \" B"
    }
    assert_haml_renders <<OUT, <<IN
<div foo="A &lt; &amp; &gt; ' &quot; B" />
<div foo="A < & > ' " B" />
OUT
%div{:foo => @foo}/
%div{:foo => @foo.mark_as_xss_protected}/
IN
    # Note that '/" explicitly marked as XSS-protected can break validity
  end
end

Version data entries

26 entries across 26 versions & 5 rubygems

Version Path
codez-tarantula-0.5.5 vendor/xss-shield/test/test_haml.rb
codez-tarantula-0.5.4 vendor/xss-shield/test/test_haml.rb
artmotion-xss_shield-0.0.1 test/test_haml.rb
artmotion-xss_shield-0.0.2 test/test_haml.rb
relevance-tarantula-0.0.1 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.2 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.3 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.5 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.6 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.7.1 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.7 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.8.0 vendor/xss-shield/test/test_haml.rb
relevance-tarantula-0.0.8.1 vendor/xss-shield/test/test_haml.rb
romanbsd-tarantula-0.1.8 vendor/xss-shield/test/test_haml.rb
romanbsd-tarantula-0.2.0 vendor/xss-shield/test/test_haml.rb
codez-tarantula-0.5.3 vendor/xss-shield/test/test_haml.rb
codez-tarantula-0.5.1 vendor/xss-shield/test/test_haml.rb
codez-tarantula-0.5.0 vendor/xss-shield/test/test_haml.rb
tarantula-0.5.1 vendor/xss-shield/test/test_haml.rb
tarantula-0.5.0 vendor/xss-shield/test/test_haml.rb