From b032ebc18e754ee5e66731f3b66599e0ded6bc20 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 30 Jan 2020 19:21:02 +0000 Subject: [PATCH] prevent Template::AutoFilter taking action on CSV output --- Changes | 6 ++++++ lib/App/Netdisco/Web.pm | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Changes b/Changes index aaa374e3..b54b9102 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.044012 - 2020-XX-XX + + [BUG FIXES] + + * prevent Template::AutoFilter taking action on CSV output + 2.044011 - 2020-01-26 [BUG FIXES] diff --git a/lib/App/Netdisco/Web.pm b/lib/App/Netdisco/Web.pm index abff36dd..961e0570 100644 --- a/lib/App/Netdisco/Web.pm +++ b/lib/App/Netdisco/Web.pm @@ -205,6 +205,30 @@ hook 'before_template' => sub { $Template::Stash::PRIVATE = undef; }; +# prevent Template::AutoFilter taking action on CSV output +hook 'before_template' => sub { + my $template_engine = engine 'template'; + if (not request->is_ajax + and header('Content-Type') + and header('Content-Type') eq 'text/comma-separated-values' ) { + + $template_engine->{config}->{AUTO_FILTER} = 'none'; + $template_engine->init(); + } + # debug $template_engine->{config}->{AUTO_FILTER}; +}; +hook 'after_template_render' => sub { + my $template_engine = engine 'template'; + if (not request->is_ajax + and header('Content-Type') + and header('Content-Type') eq 'text/comma-separated-values' ) { + + $template_engine->{config}->{AUTO_FILTER} = 'html_entity'; + $template_engine->init(); + } + # debug $template_engine->{config}->{AUTO_FILTER}; +}; + # workaround for Swagger plugin weird response body hook 'after' => sub { my $r = shift; # a Dancer::Response