<s> from django import template <EOL> from django . template import loader <EOL> from openstack_dashboard . test import helpers as test <EOL> class FakeUser ( object ) : <EOL> username = "<STR_LIT>" <EOL> class TemplateRenderTest ( test . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_openrc_html_escape ( self ) : <EOL> context = { <EOL> "<STR_LIT:user>" : FakeUser ( ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" } <EOL> out = loader . render_to_string ( <EOL> '<STR_LIT>' , <EOL> context , <EOL> template . Context ( context ) ) <EOL> self . assertFalse ( "<STR_LIT>" in out ) <EOL> self . assertTrue ( "<STR_LIT>" in out ) <EOL> def test_openrc_html_evil_shell_escape ( self ) : <EOL> context = { <EOL> "<STR_LIT:user>" : FakeUser ( ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' } <EOL> out = loader . render_to_string ( <EOL> '<STR_LIT>' , <EOL> context , <EOL> template . Context ( context ) ) <EOL> self . assertFalse ( '<STR_LIT>' in out ) <EOL> self . assertTrue ( '<STR_LIT>' in out ) <EOL> def test_openrc_html_evil_shell_backslash_escape ( self ) : <EOL> context = { <EOL> "<STR_LIT:user>" : FakeUser ( ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' } <EOL> out = loader . render_to_string ( <EOL> '<STR_LIT>' , <EOL> context , <EOL> template . Context ( context ) ) <EOL> self . assertFalse ( '<STR_LIT>' in out ) <EOL> self . assertFalse ( '<STR_LIT>' in out ) <EOL> self . assertTrue ( '<STR_LIT>' in out ) </s>
