Skip Menu |

This queue is for tickets about the Regexp-Common CPAN distribution.

Report information
The Basics
Id: 104508
Status: rejected
Priority: 0/
Queue: Regexp-Common

People
Owner: Nobody in particular
Requestors: andrnils [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug in Regexp::Common::net
Date: Tue, 19 May 2015 00:26:18 +0200
To: bug-Regexp-Common [...] rt.cpan.org
From: Andreas Nilsson <andrnils [...] gmail.com>
Hello, I've been trying to get Regexp::Common::net to distinguish some possible ip address, both ipv4 and ipv6, however I noticed some bugs: while ( <> ) { /$RE{net}{IPv4}/ and print "ipv4\n"; } as reg.pl I get $ echo 1.1.1.1 | ./reg.pl ipv4 andrnils@tallant:~/Downloads/src 00:19:48 0 $ echo 111111111.1.1.1 | ./reg.pl ipv4 andrnils@tallant:~/Downloads/src 00:19:53 0 $ echo 1111aaa11111.1.1.1 | ./reg.pl ipv4 andrnils@tallant:~/Downloads/src 00:21:17 0 $ echo 1111aaa1111111111111111111111.1.1.1 | ./reg.pl ipv4 Those are not ipv4 address. I think the regexp lacks some specifics, telling to consider the whole input, ie add ^( regexp )\$ to the create lines makes it behave. Seems to be the same for ipv6. Best regards Andreas Nilsson
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #104508] Bug in Regexp::Common::net
Date: Tue, 19 May 2015 08:15:32 +0200
To: Andreas Nilsson via RT <bug-Regexp-Common [...] rt.cpan.org>
From: Abigail <abigail [...] abigail.be>
On Mon, May 18, 2015 at 06:26:48PM -0400, Andreas Nilsson via RT wrote: Show quoted text
> Mon May 18 18:26:47 2015: Request 104508 was acted upon. > Transaction: Ticket created by andrnils@gmail.com > Queue: Regexp-Common > Subject: Bug in Regexp::Common::net > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: andrnils@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=104508 > > > > Hello, > > I've been trying to get Regexp::Common::net to distinguish some possible ip > address, both ipv4 and ipv6, however I noticed some bugs: > > while ( <> ) { > > /$RE{net}{IPv4}/ and print "ipv4\n"; > > } > > > as reg.pl I get > > $ echo 1.1.1.1 | ./reg.pl > > ipv4 > > andrnils@tallant:~/Downloads/src 00:19:48 0 > > $ echo 111111111.1.1.1 | ./reg.pl > > ipv4 > > andrnils@tallant:~/Downloads/src 00:19:53 0 > > $ echo 1111aaa11111.1.1.1 | ./reg.pl > > ipv4 > > andrnils@tallant:~/Downloads/src 00:21:17 0 > > $ echo 1111aaa1111111111111111111111.1.1.1 | ./reg.pl > > ipv4 > > > Those are not ipv4 address. I think the regexp lacks some specifics, > telling to consider the whole input, ie add ^( regexp )\$ to the create > lines makes it behave. Seems to be the same for ipv6.
This is not a bug, this behaviour is intentional. Each of the examples you give are strings that contain an IP4v4 address, and hence, the pattern matches. If you want anchors, you will have to supply them yourselves; not just for the IPv4 addresses, but for all the patterns of Regexp::Common. If the patterns would be anchored, it would be very hard to interpolate them in a larger regular expression. This is explained in the manual page of Regexp::Common, under the section NOT A BUG Regards, Abigail
Subject: Re: [rt.cpan.org #104508] Bug in Regexp::Common::net
Date: Tue, 19 May 2015 09:02:36 +0200
To: bug-Regexp-Common [...] rt.cpan.org
From: Andreas Nilsson <andrnils [...] gmail.com>
On Tue, May 19, 2015 at 8:16 AM, Abigail via RT < bug-Regexp-Common@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=104508 > > > On Mon, May 18, 2015 at 06:26:48PM -0400, Andreas Nilsson via RT wrote:
> > Mon May 18 18:26:47 2015: Request 104508 was acted upon. > > Transaction: Ticket created by andrnils@gmail.com > > Queue: Regexp-Common > > Subject: Bug in Regexp::Common::net > > Broken in: (no value) > > Severity: (no value) > > Owner: Nobody > > Requestors: andrnils@gmail.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=104508 > > > > > > > Hello, > > > > I've been trying to get Regexp::Common::net to distinguish some possible
> ip
> > address, both ipv4 and ipv6, however I noticed some bugs: > > > > while ( <> ) { > > > > /$RE{net}{IPv4}/ and print "ipv4\n"; > > > > } > > > > > > as reg.pl I get > > > > $ echo 1.1.1.1 | ./reg.pl > > > > ipv4 > > > > andrnils@tallant:~/Downloads/src 00:19:48 0 > > > > $ echo 111111111.1.1.1 | ./reg.pl > > > > ipv4 > > > > andrnils@tallant:~/Downloads/src 00:19:53 0 > > > > $ echo 1111aaa11111.1.1.1 | ./reg.pl > > > > ipv4 > > > > andrnils@tallant:~/Downloads/src 00:21:17 0 > > > > $ echo 1111aaa1111111111111111111111.1.1.1 | ./reg.pl > > > > ipv4 > > > > > > Those are not ipv4 address. I think the regexp lacks some specifics, > > telling to consider the whole input, ie add ^( regexp )\$ to the create > > lines makes it behave. Seems to be the same for ipv6.
> > > > This is not a bug, this behaviour is intentional. > > Each of the examples you give are strings that contain an IP4v4 > address, and hence, the pattern matches. > > If you want anchors, you will have to supply them yourselves; not > just for the IPv4 addresses, but for all the patterns of Regexp::Common. > If the patterns would be anchored, it would be very hard to > interpolate them in a larger regular expression. > > This is explained in the manual page of Regexp::Common, under the > section NOT A BUG > > > Regards, > > > Abigail > >
Hello, now that was unexpected. I'll add anchors myself then. However, while there are ipv4 address in my examples above, where are they in the following examples: $ echo 11191.91111.911119.91111 | ./reg.pl ipv4 $ echo 5555.5555.5555.5555 | ./reg.pl ipv4 $ echo 1g.1g.1g.1g | ./reg.pl ipv4 Best regards Andreas
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #104508] Bug in Regexp::Common::net
Date: Tue, 19 May 2015 11:00:41 +0200
To: Andreas Nilsson via RT <bug-Regexp-Common [...] rt.cpan.org>
From: Abigail <abigail [...] abigail.be>
On Tue, May 19, 2015 at 03:02:47AM -0400, Andreas Nilsson via RT wrote: Show quoted text
> Queue: Regexp-Common > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=104508 > > > On Tue, May 19, 2015 at 8:16 AM, Abigail via RT < > bug-Regexp-Common@rt.cpan.org> wrote: >
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=104508 > > > > > On Mon, May 18, 2015 at 06:26:48PM -0400, Andreas Nilsson via RT wrote:
> > > Mon May 18 18:26:47 2015: Request 104508 was acted upon. > > > Transaction: Ticket created by andrnils@gmail.com > > > Queue: Regexp-Common > > > Subject: Bug in Regexp::Common::net > > > Broken in: (no value) > > > Severity: (no value) > > > Owner: Nobody > > > Requestors: andrnils@gmail.com > > > Status: new > > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=104508 > > > > > > > > > > Hello, > > > > > > I've been trying to get Regexp::Common::net to distinguish some possible
> > ip
> > > address, both ipv4 and ipv6, however I noticed some bugs: > > > > > > while ( <> ) { > > > > > > /$RE{net}{IPv4}/ and print "ipv4\n"; > > > > > > } > > > > > > > > > as reg.pl I get > > > > > > $ echo 1.1.1.1 | ./reg.pl > > > > > > ipv4 > > > > > > andrnils@tallant:~/Downloads/src 00:19:48 0 > > > > > > $ echo 111111111.1.1.1 | ./reg.pl > > > > > > ipv4 > > > > > > andrnils@tallant:~/Downloads/src 00:19:53 0 > > > > > > $ echo 1111aaa11111.1.1.1 | ./reg.pl > > > > > > ipv4 > > > > > > andrnils@tallant:~/Downloads/src 00:21:17 0 > > > > > > $ echo 1111aaa1111111111111111111111.1.1.1 | ./reg.pl > > > > > > ipv4 > > > > > > > > > Those are not ipv4 address. I think the regexp lacks some specifics, > > > telling to consider the whole input, ie add ^( regexp )\$ to the create > > > lines makes it behave. Seems to be the same for ipv6.
> > > > > > > > This is not a bug, this behaviour is intentional. > > > > Each of the examples you give are strings that contain an IP4v4 > > address, and hence, the pattern matches. > > > > If you want anchors, you will have to supply them yourselves; not > > just for the IPv4 addresses, but for all the patterns of Regexp::Common. > > If the patterns would be anchored, it would be very hard to > > interpolate them in a larger regular expression. > > > > This is explained in the manual page of Regexp::Common, under the > > section NOT A BUG > > > > > > Regards, > > > > > > Abigail > > > >
> Hello, > > now that was unexpected. I'll add anchors myself then. > > However, while there are ipv4 address in my examples above, where are they > in the following examples: > > $ echo 11191.91111.911119.91111 | ./reg.pl > > ipv4 > > $ echo 5555.5555.5555.5555 | ./reg.pl > > ipv4 > > $ echo 1g.1g.1g.1g | ./reg.pl > > ipv4 >
I cannot reproduce that: #!/opt/perl/bin/perl use 5.010; use strict; use warnings; no warnings 'syntax'; use Regexp::Common; my $pat = $RE {net} {IPv4} {-keep}; while (<DATA>) { chomp; say /$pat/ ? "$_: matched ($1)" : "$_: no match"; } __DATA__ 11191.91111.911119.91111 5555.5555.5555.5555 1g.1g.1g.1g This results in: 11191.91111.911119.91111: no match 5555.5555.5555.5555: no match 1g.1g.1g.1g: no match Abigail
Not a bug