Skip Menu |

This queue is for tickets about the HTTP-DAV CPAN distribution.

Report information
The Basics
Id: 123528
Status: resolved
Priority: 0/
Queue: HTTP-DAV

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

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



Subject: the clone method doesn't properly respect class
It does "$self = @_" which means $self is 1, which means ref($self) is undef, and bless into undef means bless into __PACKAGE__ Patch attached. -- rjbs
Subject: 0001-clone-fix-how-self-comes-off-the-stack.patch
From 8c18a38f155daeaa23a44f3f6cd487e3f243d9e2 Mon Sep 17 00:00:00 2001 From: Ricardo Signes <rjbs@cpan.org> Date: Mon, 6 Nov 2017 10:47:24 -0500 Subject: [PATCH] clone: fix how $self comes off the stack without this, cloning will lose class --- lib/HTTP/DAV.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/HTTP/DAV.pm b/lib/HTTP/DAV.pm index cd2995d..81062f9 100644 --- a/lib/HTTP/DAV.pm +++ b/lib/HTTP/DAV.pm @@ -36,7 +36,7 @@ sub new { ########################################################################### sub clone { - my $self = @_; + my ($self) = @_; my $class = ref($self); my %clone = %{$self}; bless {%clone}, $class; -- 2.14.2
Il Lun 06 Nov 2017 10:49:04, RJBS ha scritto: Show quoted text
> It does "$self = @_" which means $self is 1, which means ref($self) is > undef, and bless into undef means bless into __PACKAGE__ > > Patch attached.
Thanks Ricardo. Is this patch needed because of a recent or upcoming change in perl, or it's always been needed? I will patch it and release a new version on CPAN within the week. Cheers,
On 2017-11-07 17:03:08, COSIMO wrote: Show quoted text
> > Is this patch needed because of a recent or upcoming change in perl, > or it's always been needed?
It's always been needed. This code would work if HTTP::DAV is used directly, but in a subclass, the bless would be into the wrong package. This would've been the case since perl 5.0 -- rjbs
On Mon Nov 20 01:27:04 2017, RJBS wrote: Show quoted text
> On 2017-11-07 17:03:08, COSIMO wrote:
> > > > Is this patch needed because of a recent or upcoming change in perl, > > or it's always been needed?
> > It's always been needed. This code would work if HTTP::DAV is used > directly, but in a subclass, the bless would be into the wrong > package. This would've been the case since perl 5.0
I've submitted a pull request to the git repo patching this issue, and have a test proving the fix works. https://github.com/cosimo/perl5-http-dav/pull/4 Roy
Should be fixed in 0.49, soon on CPAN.