Skip Menu |

This queue is for tickets about the Set-Array CPAN distribution.

Report information
The Basics
Id: 81971
Status: resolved
Priority: 0/
Queue: Set-Array

People
Owner: Nobody in particular
Requestors: henrik [...] jobindex.dk
Cc:
AdminCc:

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



Subject: Delete and quoting
Date: Fri, 14 Dec 2012 08:25:59 +0100
To: <bug-Set-Array [...] rt.cpan.org>
From: Henrik Hald Nørgaard <henrik [...] jobindex.dk>
The following code fails: perl -E 'use Set::Array; my $set = Set::Array->new(qw(1 2 3)); $set->delete("(");' because Set::Array->delete does not quote the arguments to delete before interpolating them into a regular expression. Version of Perl: This is perl 5, version 16, subversion 2 (v5.16.2) built for x86_64-linux Operating system: CentOS release 5.8 (Final) Kind regards Henrik Hald Nørgaard, Programmør Jobindex A/S, Holger Danskes Vej 91, 2000 Frederiksberg Tlf.: +45 38 32 33 55, dir.: +45 38 32 33 81 <http://www.jobindex.dk> www.jobindex.dk
Hi Yes, you're right. I've uploaded V 0.27 to CPAN. Here is the new part of the CHANGES file: 0.27 Sat Dec 15 07:19:00 2012 - Fix RT#81971, kindly reported by Henrik Hald Nørgaard. When special chars, as used in regexps, are set members, or used to find set members, they must be quoted with \Q$value\E inside regexps. This fix was applied to count(), delete(), exists(), index() and rindex(). - Add t/rt.81971.t to exercise the new code. - While examining the code for this fix, I found a couple of other bugs: In index() and rindex(), the value searched for was compared with each set member using this regexp, /$value/, instead of this regexp, /$value$/. The missing, trailing, $ meant that the member could match just the prefix of $value, rather than match the value exactly. So in those 2 methods the tests are now /\Q$value\E$/. The other 3 methods mentioned above already used /$value$/. Thanx for the report.
Subject: SV: [rt.cpan.org #81971] Delete and quoting
Date: Tue, 18 Dec 2012 09:00:04 +0100
To: <bug-Set-Array [...] rt.cpan.org>
From: Henrik Hald Nørgaard <henrik [...] jobindex.dk>
Hi Thank you for fixing this problem very fast. In index and rindex shouldn't you use /^\Q$value\E$/? These methods are now testing if the value is a suffix of a member of the list. Example: perl -E 'use Set::Array; my $set = Set::Array->new("dog", "horse", "cat"); say $set->index("at");' which prints "2". Kind regards Henrik Hald Nørgaard, Programmør Jobindex A/S, Holger Danskes Vej 91, 2000 Frederiksberg Tlf.: +45 38 32 33 55, dir.: +45 38 32 33 81 www.jobindex.dk Show quoted text
-----Oprindelig meddelelse----- Fra: RSAVAGE via RT [mailto:bug-Set-Array@rt.cpan.org] Sendt: 14. december 2012 23:20 Til: henrik@jobindex.dk Emne: [rt.cpan.org #81971] Delete and quoting <URL: https://rt.cpan.org/Ticket/Display.html?id=81971 > Hi Yes, you're right. I've uploaded V 0.27 to CPAN. Here is the new part of the CHANGES file: 0.27 Sat Dec 15 07:19:00 2012 - Fix RT#81971, kindly reported by Henrik Hald Nørgaard. When special chars, as used in regexps, are set members, or used to find set members, they must be quoted with \Q$value\E inside regexps. This fix was applied to count(), delete(), exists(), index() and rindex(). - Add t/rt.81971.t to exercise the new code. - While examining the code for this fix, I found a couple of other bugs: In index() and rindex(), the value searched for was compared with each set member using this regexp, /$value/, instead of this regexp, /$value$/. The missing, trailing, $ meant that the member could match just the prefix of $value, rather than match the value exactly. So in those 2 methods the tests are now /\Q$value\E$/. The other 3 methods mentioned above already used /$value$/. Thanx for the report.
Subject: Re: SV: [rt.cpan.org #81971] Delete and quoting
Date: Wed, 19 Dec 2012 09:14:30 +1100
To: bug-Set-Array [...] rt.cpan.org
From: Ron Savage <ron [...] savage.net.au>
Hi On 18/12/12 19:00, Henrik Hald Nørgaard via RT wrote: Show quoted text
> Queue: Set-Array > Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=81971> > > Hi > > Thank you for fixing this problem very fast. > > In index and rindex shouldn't you use /^\Q$value\E$/? These methods are now testing if the value is a suffix of a member of the list.
Yes, you're right again! I've uploaded V 0.28 to CPAN. Thanx. Show quoted text
> Example: > > perl -E 'use Set::Array; my $set = Set::Array->new("dog", "horse", "cat"); say $set->index("at");' > > which prints "2". > > Kind regards > > Henrik Hald Nørgaard, Programmør > Jobindex A/S, Holger Danskes Vej 91, 2000 Frederiksberg > Tlf.: +45 38 32 33 55, dir.: +45 38 32 33 81 > > www.jobindex.dk > > -----Oprindelig meddelelse----- > Fra: RSAVAGE via RT [mailto:bug-Set-Array@rt.cpan.org] > Sendt: 14. december 2012 23:20 > Til: henrik@jobindex.dk > Emne: [rt.cpan.org #81971] Delete and quoting > > <URL: https://rt.cpan.org/Ticket/Display.html?id=81971> > > Hi > > Yes, you're right. > > I've uploaded V 0.27 to CPAN. Here is the new part of the CHANGES file: > > 0.27 Sat Dec 15 07:19:00 2012 > > - Fix RT#81971, kindly reported by Henrik Hald Nørgaard. > When special chars, as used in regexps, are set members, or used to find set members, they must be quoted with \Q$value\E inside regexps. > This fix was applied to count(), delete(), exists(), index() and rindex(). > > - Add t/rt.81971.t to exercise the new code. > > - While examining the code for this fix, I found a couple of other bugs: > In index() and rindex(), the value searched for was compared with each set member using this regexp, /$value/, instead of this regexp, /$value$/. The missing, trailing, $ meant that the member could match just the prefix of $value, rather than match the value exactly. So in those 2 methods the tests are now /\Q$value\E$/. The other 3 methods mentioned above already used /$value$/. > > > Thanx for the report. > > >
-- Ron Savage http://savage.net.au/ Ph: 0421 920 622
Fixed in V 0.28.