prevent Template::AutoFilter taking action on CSV output

This commit is contained in:
Oliver Gorwits
2020-01-30 19:21:02 +00:00
parent 16e451c77c
commit b032ebc18e
2 changed files with 30 additions and 0 deletions

View File

@@ -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]

View File

@@ -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