Skip Menu |

This queue is for tickets about the Authen-Htpasswd CPAN distribution.

Report information
The Basics
Id: 40129
Status: open
Priority: 0/
Queue: Authen-Htpasswd

People
Owner: EDENC [...] cpan.org
Requestors: jschrod [...] acm.org
Cc:
AdminCc:

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



Subject: UNIVERSAL::isa() must be used as function
If one has a username with a leading digit, Authen::Htpasswd throws the error "Can't call method "isa" without a package or object reference". (Such a user was created by other means, not by Authen::Htpasswd.) That's because the isa method can only be used on blessed references and strings that are package names. If one uses the isa() function, it works. I've attached a patch. Thanks for your work on this module!
Subject: Authen-Htpasswd.isa-usage.patch
Index: lib/Authen/Htpasswd.pm =================================================================== RCS file: /shared/CVS/depot/lsfts/code/lib/Authen/Htpasswd.pm,v retrieving revision 1.1 diff -u -r1.1 Htpasswd.pm --- lib/Authen/Htpasswd.pm 14 Aug 2008 15:49:33 -0000 1.1 +++ lib/Authen/Htpasswd.pm 17 Oct 2008 11:10:39 -0000 @@ -6,6 +6,7 @@ use IO::File; use IO::LockedFile; use Authen::Htpasswd::User; +use UNIVERSAL; use vars qw{$VERSION $SUFFIX}; BEGIN { @@ -240,7 +241,7 @@ sub delete_user { my $self = shift; - my $username = $_[0]->isa('Authen::Htpasswd::User') ? $_[0]->username : $_[0]; + my $username = UNIVERSAL::isa($_[0], 'Authen::Htpasswd::User') ? $_[0]->username : $_[0]; my ($old,$new) = $self->_start_rewrite; while (defined(my $line = <$old>)) { @@ -261,7 +262,7 @@ sub _get_user { my $self = shift; - return $_[0] if $_[0]->isa('Authen::Htpasswd::User'); + return $_[0] if UNIVERSAL::isa($_[0], 'Authen::Htpasswd::User'); my $attr = ref $_[-1] eq 'HASH' ? pop @_ : {}; $attr->{encrypt_hash} ||= $self->encrypt_hash; $attr->{check_hashes} ||= $self->check_hashes;
On 2008-10-17 04:52:31, jschrod wrote: Show quoted text
> If one has a username with a leading digit, Authen::Htpasswd throws the > error "Can't call method "isa" without a package or object reference". > (Such a user was created by other means, not by Authen::Htpasswd.) > > That's because the isa method can only be used on blessed references and > strings that are package names. If one uses the isa() function, it works.
I don't think this is a good change. UNIVERSAL::isa is deprecated and is strongly advised against. Is it not acceptable to check blessed($obj) first? Also, a test case would be helpful, so we can write a unit test for this while fixing it.