Bugzilla – Attachment 165832 Details for
Bug 5920
Remove HTML from downloaded reports in CSV format
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5920: Strip HTML from report exports
Bug-5920-Strip-HTML-from-report-exports.patch (text/plain), 3.47 KB, created by
Martin Renvoize (ashimema)
on 2024-04-30 09:02:25 UTC
(
hide
)
Description:
Bug 5920: Strip HTML from report exports
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-30 09:02:25 UTC
Size:
3.47 KB
patch
obsolete
>From 9e5147df9d508d50798a20f596edfc75d5da6105 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 10 Jan 2022 10:45:54 +0100 >Subject: [PATCH] Bug 5920: Strip HTML from report exports > >This patch uses HTML::Restrict to strip out HTML tags from the CSV >download of reports. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > reports/guided_reports.pl | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index 57b7abd06e8..a4e6bdd3bbb 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -40,6 +40,7 @@ use Koha::Util::OpenDocument qw( generate_ods ); > use Koha::Notice::Templates; > use Koha::TemplateUtils qw( process_tt ); > use C4::ClassSource qw( GetClassSources ); >+use HTML::Restrict; > > =head1 NAME > >@@ -620,6 +621,7 @@ elsif ($op eq 'export'){ > my $format = $input->param('format'); > my $reportname = $input->param('reportname'); > my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ; >+ my $hr = HTML::Restrict->new(); > > ($sql, undef) = $report->prep_report( \@param_names, \@sql_params ); > my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } ); >@@ -628,9 +630,9 @@ elsif ($op eq 'export'){ > if ($format eq 'tab') { > $type = 'application/octet-stream'; > $content .= join("\t", header_cell_values($sth)) . "\n"; >- $content = Encode::decode('UTF-8', $content); >+ $content = $hr->process(Encode::decode('UTF-8', $content)); > while (my $row = $sth->fetchrow_arrayref()) { >- $content .= join("\t", map { $_ // '' } @$row) . "\n"; >+ $content .= join("\t", $hr->process(@$row)) . "\n"; > } > } else { > if ( $format eq 'csv' ) { >@@ -639,13 +641,15 @@ elsif ($op eq 'export'){ > my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); > $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); > if ($csv->combine(header_cell_values($sth))) { >- $content .= Encode::decode('UTF-8', $csv->string()) . "\n"; >+ $content .= $hr->process(Encode::decode('UTF-8', $csv->string())) . "\n"; >+ > } else { > push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ; > } > while (my $row = $sth->fetchrow_arrayref()) { > if ($csv->combine(@$row)) { >- $content .= $csv->string() . "\n"; >+ $content .= $hr->process($csv->string()) . "\n"; >+ > } else { > push @$q_errors, { combine => $csv->error_diag() } ; > } >@@ -666,7 +670,8 @@ elsif ($op eq 'export'){ > foreach my $sql_row ( @$sql_rows ) { > my @content_row; > foreach my $sql_cell ( @$sql_row ) { >- push @content_row, Encode::encode( 'UTF8', $sql_cell ); >+ push @content_row, $hr->process(Encode::encode( 'UTF8', $sql_cell )); >+ > } > push @$ods_content, \@content_row; > } >-- >2.44.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5920
:
161709
|
161710
|
161983
|
161984
|
161985
|
165689
|
165690
|
165691
| 165832 |
165833
|
165834