Regexp-IPv6-0.03/0000755000175000017500000000000011332775031012450 5ustar salvasalvaRegexp-IPv6-0.03/META.yml0000644000175000017500000000100011332775031013710 0ustar salvasalva--- #YAML:1.0 name: Regexp-IPv6 version: 0.03 abstract: ~ author: - Salvador Fandino license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: {} no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.55_02 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Regexp-IPv6-0.03/Changes0000644000175000017500000000106611332774373013756 0ustar salvasalvaRevision history for Perl extension Regexp::IPv6. 0.03 Feb 5, 2010 - some work done in maximizing matches - addresses like xxx::xxxx: were not being rejected (bug report by Michael Erickson) - addresses like x:x:x:x:x:x:x.x.x.x were not being accepted (bug report by Michael Erickson) - more tests (contributed by Michael G. Schwern and Michael Erickson) 0.02 Jan 24, 2009 - clean up companion files 0.01 Sat Jan 24 13:03:13 2009 - original version; created by h2xs 1.23 with options -AXn Regexp::IPv6 Regexp-IPv6-0.03/MANIFEST0000644000175000017500000000022611332746115013602 0ustar salvasalvaChanges Makefile.PL MANIFEST README t/Regexp-IPv6.t lib/Regexp/IPv6.pm META.yml Module meta-data (added by MakeMaker) Regexp-IPv6-0.03/t/0000755000175000017500000000000011332775031012713 5ustar salvasalvaRegexp-IPv6-0.03/t/Regexp-IPv6.t0000644000175000017500000001104211332774275015123 0ustar salvasalva# -*- Mode: Perl -*- use Test::More tests => 198; use Regexp::IPv6 qw($IPv6_re); my $good = 1; my $re = qr/^$IPv6_re$/; my $nare = qr/($IPv6_re)/; while () { chomp; s/\s*#.*//; next if m/^$/; if (/^GOOD/) { $good = 1; next; } if (/^BAD/) { $good = 0; next; } if ($good) { ok($_ =~ $re, "good $_"); TODO: if (0) { # local $TODO = "maximize match not implemented yet"; ok(($_ =~ $nare and $1 eq $_), "full match $_") or diag("text: $_, matched: $1"); }; } else { ok($_ !~ $re, "bad $_"); } } # most of the samples below were taken from the validate_ipv6.rb # script by Christoph Petschnig (Michael Erickson pointed me there). # some samples are from the Wikipedia. # some samples contributed by Michael G. Schwern __DATA__ GOOD: ::127.0.0.1 ::1 2001:0db8:85a3:0000:0000:8a2e:0370:7334 2001:db8:85a3:0:0:8a2e:370:7334 2001:db8:85a3::8a2e:370:7334 2001:0db8:0000:0000:0000:0000:1428:57ab 2001:0db8:0000:0000:0000::1428:57ab 2001:0db8:0:0:0:0:1428:57ab 2001:0db8:0:0::1428:57ab 2001:0db8::1428:57ab 2001:db8::1428:57ab ::ffff:12.34.56.78 ::ffff:0c22:384e 2001:0db8:1234:ffff:ffff:ffff:ffff:ffff 2001:0db8:1234:0000:0000:0000:0000:0000 2001:db8:a::123 fc00:: ::ffff:0:0 2001:: 2001:10:: 2001:db8:: 2001:0000:1234:0000:0000:C1C0:ABCD:0876 3ffe:0b00:0000:0000:0001:0000:0000:000a FF02:0000:0000:0000:0000:0000:0000:0001 0000:0000:0000:0000:0000:0000:0000:0001 0000:0000:0000:0000:0000:0000:0000:0000 ::ffff:192.168.1.26 2::10 ff02::1 fe80:: 2002:: 2001:db8:: 2001:0db8:1234:: ::ffff:0:0 ::1 ::ffff:192.168.1.1 1:2:3:4:5:6:7:8 1:2:3:4:5:6::8 1:2:3:4:5::8 1:2:3:4::8 1:2:3::8 1:2::8 1::8 1::2:3:4:5:6:7 1::2:3:4:5:6 1::2:3:4:5 1::2:3:4 1::2:3 1::8 ::2:3:4:5:6:7:8 ::2:3:4:5:6:7 ::2:3:4:5:6 ::2:3:4:5 ::2:3:4 ::2:3 ::8 1:2:3:4:5:6:: 1:2:3:4:5:: 1:2:3:4:: 1:2:3:: 1:2:: 1:: 1:2:3:4:5::7:8 2001:0000:1234:0000:0000:C1C0:ABCD:0876 1:2:3:4::7:8 1:2:3::7:8 1:2::7:8 1::7:8 1:2:3:4:5:6:1.2.3.4 1:2:3:4:5::1.2.3.4 1:2:3:4::1.2.3.4 1:2:3::1.2.3.4 1:2::1.2.3.4 1::1.2.3.4 1:2:3:4::5:1.2.3.4 1:2:3::5:1.2.3.4 1:2::5:1.2.3.4 1::5:1.2.3.4 1::5:11.22.33.44 fe80::217:f2ff:254.7.237.98 fe80::217:f2ff:fe07:ed62 2001:DB8:0:0:8:800:200C:417A # unicast, full FF01:0:0:0:0:0:0:101 # multicast, full 0:0:0:0:0:0:0:1 # loopback, full 0:0:0:0:0:0:0:0 # unspecified, full 2001:DB8::8:800:200C:417A # unicast, compressed FF01::101 # multicast, compressed ::1 # loopback, compressed, non-routable 0:0:0:0:0:0:13.1.68.3 # IPv4-compatible IPv6 address, full, deprecated 0:0:0:0:0:FFFF:129.144.52.38 # IPv4-mapped IPv6 address, full ::13.1.68.3 # IPv4-compatible IPv6 address, compressed, deprecated ::FFFF:129.144.52.38 # IPv4-mapped IPv6 address, compressed fe80:0000:0000:0000:0204:61ff:fe9d:f156 fe80:0:0:0:204:61ff:fe9d:f156 fe80::204:61ff:fe9d:f156 fe80:0:0:0:204:61ff:254.157.241.86 fe80::204:61ff:254.157.241.86 fe80:: fe80::1 0000:0000:0000:0000:0000:0000:0000:0001 ::1 ::ffff:192.0.2.128 ::ffff:c000:280 BAD: 127.0.0.1 :: : 2001:0000:1234:0000:0000:C1C0:ABCD:0876 0 2001:0000:1234: 0000:0000:C1C0:ABCD:0876 02001:0000:1234:0000:0000:C1C0:ABCD:0876 # extra 0 not allowed! 2001:0000:1234:0000:00001:C1C0:ABCD:0876 # extra 0 not allowed! 3ffe:0b00:0000:0001:0000:0000:000a FF02:0000:0000:0000:0000:0000:0000:0000:0001 3ffe:b00::1::a ::1111:2222:3333:4444:5555:6666:: 1:2:3::4:5::7:8 12345::6:7:8 1::5:400.2.3.4 1::5:260.2.3.4 1::5:256.2.3.4 1::5:1.256.3.4 1::5:1.2.256.4 1::5:1.2.3.256 1::5:300.2.3.4 1::5:1.300.3.4 1::5:1.2.300.4 1::5:1.2.3.300 1::5:900.2.3.4 1::5:1.900.3.4 1::5:1.2.900.4 1::5:1.2.3.900 1::5:300.300.300.300 1::5:3000.30.30.30 1::400.2.3.4 1::260.2.3.4 1::256.2.3.4 1::1.256.3.4 1::1.2.256.4 1::1.2.3.256 1::300.2.3.4 1::1.300.3.4 1::1.2.300.4 1::1.2.3.300 1::900.2.3.4 1::1.900.3.4 1::1.2.900.4 1::1.2.3.900 1::300.300.300.300 1::3000.30.30.30 ::400.2.3.4 ::260.2.3.4 ::256.2.3.4 ::1.256.3.4 ::1.2.256.4 ::1.2.3.256 ::300.2.3.4 ::1.300.3.4 ::1.2.300.4 ::1.2.3.300 ::900.2.3.4 ::1.900.3.4 ::1.2.900.4 ::1.2.3.900 ::300.300.300.300 ::3000.30.30.30 2001:DB8:0:0:8:800:200C:417A:221 # unicast, full FF01::101::2 # multicast, compressed 1111:2222:3333:4444::5555: 1111:2222:3333::5555: 1111:2222::5555: 1111::5555: ::5555: ::: 1111: : :1111:2222:3333:4444::5555 :1111:2222:3333::5555 :1111:2222::5555 :1111::5555 :::5555 ::: 1.2.3.4:1111:2222:3333:4444::5555 1.2.3.4:1111:2222:3333::5555 1.2.3.4:1111:2222::5555 1.2.3.4:1111::5555 1.2.3.4::5555 1.2.3.4:: 123 ldkfj 2001::FFD3::57ab 2001:db8:85a3::8a2e:37023:7334 2001:db8:85a3::8a2e:370k:7334 1:2:3:4:5:6:7:8:9 1::2::3 1:::3:4:5 1:2:3::4:5:6:7:8:9 ::ffff:2.3.4 ::ffff:257.1.2.3 1.2.3.4 Regexp-IPv6-0.03/Makefile.PL0000644000175000017500000000030611332746115014422 0ustar salvasalva use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Regexp::IPv6', VERSION_FROM => 'lib/Regexp/IPv6.pm', PREREQ_PM => {}, AUTHOR => 'Salvador Fandino ' ); Regexp-IPv6-0.03/README0000644000175000017500000000074011332771522013332 0ustar salvasalvaRegexp-IPv6 =========== Regular expression for IPv6 addresses INSTALLATION To install this module type the following: perl Makefile.PL make make test make install COPYRIGHT AND LICENCE Copyright (C) 2009, 2010 by Salvador Fandino (sfandino@yahoo.com) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. Regexp-IPv6-0.03/lib/0000755000175000017500000000000011332775031013216 5ustar salvasalvaRegexp-IPv6-0.03/lib/Regexp/0000755000175000017500000000000011332775031014450 5ustar salvasalvaRegexp-IPv6-0.03/lib/Regexp/IPv6.pm0000644000175000017500000000334011332774622015577 0ustar salvasalvapackage Regexp::IPv6; our $VERSION = '0.03'; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw($IPv6_re); my $IPv4 = "((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))"; my $G = "[0-9a-fA-F]{1,4}"; my @tail = ( ":", "(:($G)?|$IPv4)", ":($IPv4|$G(:$G)?|)", "(:$IPv4|:$G(:$IPv4|(:$G){0,2})|:)", "((:$G){0,2}(:$IPv4|(:$G){1,2})|:)", "((:$G){0,3}(:$IPv4|(:$G){1,2})|:)", "((:$G){0,4}(:$IPv4|(:$G){1,2})|:)" ); our $IPv6_re = $G; $IPv6_re = "$G:($IPv6_re|$_)" for @tail; $IPv6_re = qq/:(:$G){0,5}((:$G){1,2}|:$IPv4)|$IPv6_re/; $IPv6_re =~ s/\(/(?:/g; $IPv6_re = qr/$IPv6_re/; 1; __END__ =head1 NAME Regexp::IPv6 - Regular expression for IPv6 addresses =head1 SYNOPSIS use Regexp::IPv6 qw($IPv6_re); $address =~ /^$IPv6_re$/ and print "IPv6 address\n"; =head1 DESCRIPTION This module exports the $IPv6_re regular expression that matches any valid IPv6 address as described in "RFC 2373 - 2.2 Text Representation of Addresses" but C<::>. Any string not compliant with such RFC will be rejected. To match full strings use C. =head1 COPYRIGHT AND LICENSE Copyright (C) 2009, 2010 by Salvador FandiEo (sfandino@yahoo.com) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. Additionally, you are allowed to use the regexp generated by the module in any way you want, without any restriction. For instance, you are allowed to copy it verbating in your program. =cut