From 4a651c86be0a550ff96fbe3504b7be1c84fdf457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Thu, 4 Dec 2025 15:26:14 -0300 Subject: [PATCH] Bug 40989: Fix OAI-PMH tests for CGI.pm 4.68+ CGI.pm 4.68 (shipped with Debian 13/Trixie) changed the behavior of self_url() to include a trailing slash when there's no path component. This causes OAI-PMH tests to fail as they expect URLs without trailing slashes. This patch strips the trailing slash from both the requestURL field in OAI responses and the baseURL field in Identify responses to maintain compatibility across CGI.pm versions. Test plan: 1. Start a 'trixie' KTD: $ KOHA_IMAGE=main-trixie ktd --proxy --name trixie up -d $ ktd --name trixie --wait-ready 120 2. Run the tests: $ ktd --name trixie --shell k$ prove t/db_dependent/OAI/Server.t => FAIL: Tests fail! 3. Apply this patch 5. Repeat 2 6. Repeat 1-2 with a 'bookworm' image => SUCCESS: Tests pass too! 7. Sign off :-D --- Koha/OAI/Server/Identify.pm | 1 + Koha/OAI/Server/Repository.pm | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Koha/OAI/Server/Identify.pm b/Koha/OAI/Server/Identify.pm index cb234d376a..71383c3845 100644 --- a/Koha/OAI/Server/Identify.pm +++ b/Koha/OAI/Server/Identify.pm @@ -33,6 +33,7 @@ sub new { my $baseURL = $repository->self_url(); $baseURL = $+{base_url} if $baseURL =~ m/(?.*)\?.*/; + $baseURL =~ s{/$}{}; # Strip trailing slash for CGI.pm 4.68+ compatibility my $self = $class->SUPER::new( baseURL => $baseURL, diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm index 82bc89efe7..b1812df6c8 100644 --- a/Koha/OAI/Server/Repository.pm +++ b/Koha/OAI/Server/Repository.pm @@ -157,6 +157,11 @@ sub new { $response = $class->new( $self, %attr ); } + # Strip trailing slash from requestURL for CGI.pm 4.68+ compatibility + my $url = $response->requestURL(); + $url =~ s{/$}{}; + $response->requestURL($url); + $response->set_handler( XML::SAX::Writer->new( Output => *STDOUT ) ); $response->xslt("/opac-tmpl/xslt/OAI.xslt"); $response->generate; -- 2.50.1 (Apple Git-155)