Bugzilla – Attachment 165834 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: (QA follow-up) Switch to use existing dependancy
Bug-5920-QA-follow-up-Switch-to-use-existing-depen.patch (text/plain), 4.89 KB, created by
Martin Renvoize (ashimema)
on 2024-04-30 09:02:31 UTC
(
hide
)
Description:
Bug 5920: (QA follow-up) Switch to use existing dependancy
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-30 09:02:31 UTC
Size:
4.89 KB
patch
obsolete
>From 8a71fde1aa566258dd77866dd8443fc5b3dd29ee Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 30 Apr 2024 09:59:23 +0100 >Subject: [PATCH] Bug 5920: (QA follow-up) Switch to use existing dependancy > >We already have a scrubber module we can use; This patch switches us >from the newly introduced dependancy to using the existing and well >respected Scrubber we already have. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > cpanfile | 1 - > reports/guided_reports.pl | 32 ++++++++++++++++---------------- > 2 files changed, 16 insertions(+), 17 deletions(-) > >diff --git a/cpanfile b/cpanfile >index 06dce372fee..d3c28e62d77 100644 >--- a/cpanfile >+++ b/cpanfile >@@ -52,7 +52,6 @@ requires 'Getopt::Std', '1.05'; > requires 'HTML::Entities', '3.69'; > requires 'HTML::FormatText', '1.23'; > requires 'HTML::Scrubber', '0.08'; >-requires 'HTML::Restrict', ''; > requires 'HTTP::Cookies', '1.39'; > requires 'HTTP::OAI', '3.2'; > requires 'HTTP::Request::Common', '1.26'; >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index a4e6bdd3bbb..61c29a0c0f0 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -40,7 +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; >+use C4::Scrubber; > > =head1 NAME > >@@ -620,8 +620,8 @@ elsif ($op eq 'export'){ > my @sql_params = $input->multi_param('sql_params'); > my $format = $input->param('format'); > my $reportname = $input->param('reportname'); >- my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ; >- my $hr = HTML::Restrict->new(); >+ my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format"; >+ my $scrubber = C4::Scrubber->new(); > > ($sql, undef) = $report->prep_report( \@param_names, \@sql_params ); > my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } ); >@@ -630,9 +630,9 @@ elsif ($op eq 'export'){ > if ($format eq 'tab') { > $type = 'application/octet-stream'; > $content .= join("\t", header_cell_values($sth)) . "\n"; >- $content = $hr->process(Encode::decode('UTF-8', $content)); >- while (my $row = $sth->fetchrow_arrayref()) { >- $content .= join("\t", $hr->process(@$row)) . "\n"; >+ $content = $scrubber->scrub( Encode::decode( 'UTF-8', $content ) ); >+ while ( my $row = $sth->fetchrow_arrayref() ) { >+ $content .= join( "\t", $scrubber->scrub(@$row) ) . "\n"; > } > } else { > if ( $format eq 'csv' ) { >@@ -640,18 +640,18 @@ elsif ($op eq 'export'){ > $type = 'application/csv'; > 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 .= $hr->process(Encode::decode('UTF-8', $csv->string())) . "\n"; >+ if ( $csv->combine( header_cell_values($sth) ) ) { >+ $content .= $scrubber->scrub( Encode::decode( 'UTF-8', $csv->string() ) ) . "\n"; > > } else { >- push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ; >+ push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() }; > } >- while (my $row = $sth->fetchrow_arrayref()) { >- if ($csv->combine(@$row)) { >- $content .= $hr->process($csv->string()) . "\n"; >+ while ( my $row = $sth->fetchrow_arrayref() ) { >+ if ( $csv->combine(@$row) ) { >+ $content .= $scrubber->scrub( $csv->string() ) . "\n"; > > } else { >- push @$q_errors, { combine => $csv->error_diag() } ; >+ push @$q_errors, { combine => $csv->error_diag() }; > } > } > } >@@ -667,10 +667,10 @@ elsif ($op eq 'export'){ > > # Other line in Unicode > my $sql_rows = $sth->fetchall_arrayref(); >- foreach my $sql_row ( @$sql_rows ) { >+ foreach my $sql_row (@$sql_rows) { > my @content_row; >- foreach my $sql_cell ( @$sql_row ) { >- push @content_row, $hr->process(Encode::encode( 'UTF8', $sql_cell )); >+ foreach my $sql_cell (@$sql_row) { >+ push @content_row, $scrubber->scrub( 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