Replace the deprecated module Net::Subnets with Net::CIDR::Lite.

This commit is contained in:
Colin Kuskie 2009-11-17 18:34:42 -08:00
parent 5df15c6307
commit fae8b162fa
4 changed files with 39 additions and 34 deletions

View file

@ -25,6 +25,7 @@
- fixed #11247: Survey edit screen broken - fixed #11247: Survey edit screen broken
- fixed #11246: Image.pm - Validation error - fixed #11246: Image.pm - Validation error
- fixed #11221: wrong version of Locales::Country in testEnvironment - fixed #11221: wrong version of Locales::Country in testEnvironment
- Net::Subnets has been deprecated.
7.8.4 7.8.4
- Fixed a compatibility problem between WRE and new Spectre code. - Fixed a compatibility problem between WRE and new Spectre code.

View file

@ -10,7 +10,10 @@ save you many hours of grief.
7.8.5 7.8.5
-------------------------------------------------------------------- --------------------------------------------------------------------
* WebGUI now requires Locales 0.10 or higher, to replace the deprecated * WebGUI now requires Locales 0.10 or higher, to replace the deprecated
modules Locales::Country. module Locales::Country.
* WebGUI now requires Net::CIDR::Lite 0.20 or higher, to replace the deprecated
module Net::Subnets.
* Users, no matter if they are created via anonymous registration, * Users, no matter if they are created via anonymous registration,
via the Admin Console Users screen, or via code, now always get via the Admin Console Users screen, or via code, now always get
@ -18,24 +21,24 @@ save you many hours of grief.
the Visitor account. Previously, based on how the user was created, the Visitor account. Previously, based on how the user was created,
they would get default values from different places. they would get default values from different places.
* The following style templates have been cleaned up by the TWG: * The following style templates have been cleaned up by the TWG:
- WebGUI 6 Blank Style, Style 01; Style 02, Style 03: - WebGUI 6 Blank Style, Style 01; Style 02, Style 03:
- no structural changes - no structural changes
- Fail safe: - Fail safe:
- added new CSS that is more robust and validates (in external file: style.css); - added new CSS that is more robust and validates (in external file: style.css);
- it was also necessary to update the css to work with the new navigation templates - it was also necessary to update the css to work with the new navigation templates
- changed the markup and the order of the home/login/user/admin controls at the bottom - changed the markup and the order of the home/login/user/admin controls at the bottom
- All of the above templates: - All of the above templates:
- added a link tag to wg-base.css - added a link tag to wg-base.css
- added conditional comments at the top and bottom of the body tag to be able to target - added conditional comments at the top and bottom of the body tag to be able to target
IE versions easily with css IE versions easily with css
* Added wg-base.css, which is linked to in each style template. This stylesheet is for css that * Added wg-base.css, which is linked to in each style template. This stylesheet is for css that
is used in more than one tempalte, like pagination inline icons etc. Inline styles that are is used in more than one tempalte, like pagination inline icons etc. Inline styles that are
removed from templates, will be replaced with styles in wg-base.css (and example is RFE 11182). removed from templates, will be replaced with styles in wg-base.css (and example is RFE 11182).
Elements that are styled in wg-base.css have a classname that starts with "wg-". Elements that are styled in wg-base.css have a classname that starts with "wg-".
wg-base.css replaces webgui.css, which will be removed from the site. wg-base.css replaces webgui.css, which will be removed from the site.
7.8.4 7.8.4
-------------------------------------------------------------------- --------------------------------------------------------------------

View file

@ -19,7 +19,7 @@ package WebGUI::Utility;
use Exporter; use Exporter;
use strict; use strict;
use Tie::IxHash; use Tie::IxHash;
use Net::Subnets; use Net::CIDR::Lite;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray &isInSubnet our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray &isInSubnet
@ -176,7 +176,9 @@ sub isIn {
=head2 isInSubnet ( ipAddress, subnets ) =head2 isInSubnet ( ipAddress, subnets )
Verifies whether an IP address is in a given subnet. Returns a 1 if it is, undef if there's a formatting error, or 0 if the IP is not in the list of subnets. Verifies whether an IP address is in a given subnet. Returns a 1 if it
is, undef if there's a formatting error, or 0 if the IP is not in the
list of subnets.
=head3 ipAddress =head3 ipAddress
@ -191,22 +193,21 @@ An array reference containing subnets in CIDR format. Example: 127.0.0.1/32
sub isInSubnet { sub isInSubnet {
my $ip = shift; my $ip = shift;
my $subnets = shift; my $subnets = shift;
# some validation return 0 unless @{ $subnets };
for my $cidr ( @{ $subnets } ) { for my $cidr ( @{ $subnets } ) {
my @parts = $cidr =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)$/; my @parts = $cidr =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)$/;
unless ( 5 == @parts ) { # cidr has 5 parts unless ( 5 == @parts ) { # cidr has 5 parts
return undef; return undef;
} }
unless ( 4 == grep { $_ <= 255 } @parts[0..3] ) { # each octet needs to be between 0 and 255 unless ( 4 == grep { $_ <= 255 } @parts[0..3] ) { # each octet needs to be between 0 and 255
return undef; return undef;
} }
unless ( $parts[4] <= 32 ) { # the subnet needs to be less than or equal to 32, as 32 represents only 1 ip address unless ( $parts[4] <= 32 ) { # the subnet needs to be less than or equal to 32, as 32 represents only 1 ip address
return undef; return undef;
} }
} }
my $net = Net::Subnets->new; my $net = Net::CIDR::Lite->new(@{ $subnets });
$net->subnets($subnets); if ($net->find($ip)) {
if ($net->check(\$ip)) {
return 1; return 1;
} else { } else {
return 0; return 0;

View file

@ -100,7 +100,7 @@ checkModule("XML::FeedPP", 0.40 );
checkModule("JSON", 2.12 ); checkModule("JSON", 2.12 );
checkModule("Config::JSON", "1.3.1" ); checkModule("Config::JSON", "1.3.1" );
checkModule("Text::CSV_XS", "0.64" ); checkModule("Text::CSV_XS", "0.64" );
checkModule("Net::Subnets", 0.21 ); checkModule("Net::CIDR::Lite", 0.20 );
checkModule("Finance::Quote", 1.15 ); checkModule("Finance::Quote", 1.15 );
checkModule("POE", 1.005 ); checkModule("POE", 1.005 );
checkModule("POE::Component::IKC::Server", 0.2001 ); checkModule("POE::Component::IKC::Server", 0.2001 );