From 54ad7bc8864e3df753659b5a6e00dfd0783fdde3 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 2) Run unit tests --- 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.11.0