From f36d7ee8d28c9c826131fb9bbc8b1cc538d6d3c6 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 23 Apr 2021 00:02:57 +0000 Subject: [PATCH] Bug 28200: Add workaround for Net::Netmask abbreviated values This patch adds the shortnet workaround to allow Net::Netmask to parse abbreviated values. To test: 1) Apply patch on a Debian 11 Koha 2) Run unit tests prove t/Koha/Middleware/RealIP.t 3) redo for a Debian 9 Signed-off-by: Victor Grousset/tuxayo --- Koha/Middleware/RealIP.pm | 1 + opac/ilsdi.pl | 1 + 2 files changed, 2 insertions(+) diff --git a/Koha/Middleware/RealIP.pm b/Koha/Middleware/RealIP.pm index fc9f280ff6..294a89a3f5 100644 --- a/Koha/Middleware/RealIP.pm +++ b/Koha/Middleware/RealIP.pm @@ -109,6 +109,7 @@ sub get_trusted_proxies { my @trusted_proxies_ip = split( / /, $proxies_conf ); my @trusted_proxies = (); foreach my $ip (@trusted_proxies_ip){ + local $Net::Netmask::SHORTNET_DEFAULT = 1; my $mask = Net::Netmask->new2($ip); if ($mask){ push(@trusted_proxies,$mask); diff --git a/opac/ilsdi.pl b/opac/ilsdi.pl index 1b785211ce..c4bd11ba1b 100755 --- a/opac/ilsdi.pl +++ b/opac/ilsdi.pl @@ -168,6 +168,7 @@ my @AuthorizedIPs = split( /,/, C4::Context->preference('ILS-DI:AuthorizedIPs') if (@AuthorizedIPs) { # If no filter set, allow access to everybody my $authorized = 0; foreach my $ip (@AuthorizedIPs) { + local $Net::Netmask::SHORTNET_DEFAULT = 1; my $netmask = Net::Netmask->new2($ip); if ( $netmask && $netmask->match( $ENV{REMOTE_ADDR} ) ) { $authorized = 1; -- 2.31.1