X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flive_redirect_body.t;h=8b9d62c8615b917b775f72a6edb262897224d3ec;hp=b6d4c96f7b2f5ca94fc88ece176238bfb138cec4;hb=f82e1b2b114c99ad6712cb93003338ae5d0423a5;hpb=13e3699abaac396381c0dc9283033223ce2e310f diff --git a/t/live_redirect_body.t b/t/live_redirect_body.t index b6d4c96..8b9d62c 100644 --- a/t/live_redirect_body.t +++ b/t/live_redirect_body.t @@ -40,9 +40,24 @@ use Test::More; is( $response->code, 302, 'Response Code' ); # When the developer sets both the content body and content type, the set content body and content_type should get through. - is( $response->header( 'Content-Type' ), 'text/plain', 'Content Type' ); + like( $response->header( 'Content-Type' ), qr{text/plain}, 'Content Type' ); like( $response->content, qr/kind sir/, 'Content contains content set by the Controller' ); } +# test redirect with dodgy host +{ + local $Catalyst::Test::default_host = "-->\">'>'\""; + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_redirect_uri_for'); + + ok( my $response = request($request), 'Request' ); + is( $response->code, 302, 'Response Code' ); + + # When no body and no content_type has been set, redirecting should set both. + is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); + like( $response->content, qr//, 'Content contains HTML body' ); + like( $response->content, qr/href="[^"]+">here<\/a>/, 'link doesn\'t have xss' ); +} + done_testing;