Bugzilla – Attachment 92219 Details for
Bug 23329
tracklinks.pl accepts any url from a parameter for proxying if not tracking
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23329: Fix tests
Bug-23329-Fix-tests.patch (text/plain), 3.20 KB, created by
Martin Renvoize (ashimema)
on 2019-08-15 07:58:00 UTC
(
hide
)
Description:
Bug 23329: Fix tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-08-15 07:58:00 UTC
Size:
3.20 KB
patch
obsolete
>From 58d85a36729e686e72eff26ccc025c71a5725e25 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 14 Aug 2019 14:56:48 -0400 >Subject: [PATCH] Bug 23329: Fix tests > >- www.google.com vs https://www.google.com >- Remove transaction otherwise data are not available from webserver >- Use new C4::Output::output_error to avoid 302 (redirect) > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > opac/tracklinks.pl | 6 ++++-- > t/db_dependent/www/regressions.t | 11 ++++------- > 2 files changed, 8 insertions(+), 9 deletions(-) > >diff --git a/opac/tracklinks.pl b/opac/tracklinks.pl >index 6518faee2c..4f2ffcca93 100755 >--- a/opac/tracklinks.pl >+++ b/opac/tracklinks.pl >@@ -22,6 +22,7 @@ use Modern::Perl; > use C4::Context; > use C4::Auth qw(checkauth); > use C4::Biblio; >+use C4::Output; > use Koha::Items; > use Koha::Linktracker; > use CGI qw ( -utf8 ); >@@ -56,8 +57,9 @@ if ($uri && ($biblionumber || $itemnumber) ) { > > my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); > my $marc_urls = $record ? C4::Biblio::GetMarcUrls($record, C4::Context->preference('marcflavour')) : []; >+ > if ( ( any { $_ eq $uri } map { $_->{MARCURL} } @$marc_urls ) >- || Koha::Items->search( { itemnumber => $itemnumber, uri => $uri } )->count ) >+ || ( $itemnumber && Koha::Items->search( { itemnumber => $itemnumber, uri => $uri } )->count ) ) > { > $tracker->trackclick( > { >@@ -72,5 +74,5 @@ if ($uri && ($biblionumber || $itemnumber) ) { > } > } > >-print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early >+output_error( $cgi, '404' ); > exit; >diff --git a/t/db_dependent/www/regressions.t b/t/db_dependent/www/regressions.t >index 788e1bb13b..c661a6fed4 100644 >--- a/t/db_dependent/www/regressions.t >+++ b/t/db_dependent/www/regressions.t >@@ -38,9 +38,7 @@ my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > > subtest 'open redirection vulnerabilities in tracklinks' => sub { >- plan tests => 30; >- >- $schema->storage->txn_begin; >+ plan tests => 36; > > # No URI's > my $biblio = $builder->build_sample_biblio(); >@@ -58,12 +56,12 @@ subtest 'open redirection vulnerabilities in tracklinks' => sub { > $biblio = $builder->build_sample_biblio(); > my $biblionumber3 = $biblio->biblionumber; > $record = $biblio->metadata->record; >- $new856 = MARC::Field->new( '856', '', '', u => "www.google.com" ); >+ $new856 = MARC::Field->new( '856', '', '', u => "http://www.google.com" ); > $record->insert_fields_ordered($new856); > C4::Biblio::ModBiblio( $record, $biblionumber3 ); > > # URI at Item level >- my $item = $builder->build_sample_item( { uri => 'www.google.com' } ); >+ my $item = $builder->build_sample_item( { uri => 'http://www.google.com' } ); > my $itemnumber1 = $item->itemnumber; > > # Incorrect URI at Item level >@@ -132,6 +130,5 @@ subtest 'open redirection vulnerabilities in tracklinks' => sub { > ->status_is( 404, "404 for itemnumber containing different URI" ); > $t->get_ok( $opac . $good_itemnumber ) > ->status_is( 302, "302 for itemnumber with matching URI" ); >- >- $schema->storage->txn_rollback; > }; >+ >-- >2.20.1
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 23329
:
91566
|
91572
|
91573
|
91759
|
91760
|
92109
|
92110
|
92111
|
92112
|
92187
|
92188
|
92198
|
92199
|
92200
|
92212
|
92213
|
92214
|
92215
|
92216
|
92217
|
92218
|
92219
|
92220
|
92223
|
92224
|
92225
|
92226
|
92227
|
92228
|
92229
|
92230
|
92231
|
92262
|
92263
|
92264
|
92265
|
92266
|
92267
|
92268
|
92269