Skip Menu |

This queue is for tickets about the HTML-Parser CPAN distribution.

Report information
The Basics
Id: 27567
Status: resolved
Priority: 0/
Queue: HTML-Parser

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

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



Subject: suppress a warning when encode_entities is called with undef
HTML-Parser-3.56 using perl v5.8.6 OS X administrators-computer-4:~/Desktop/web download msouth$ perl -MHTML::Entities -w -e 'print HTML::Entities::encode_entities(undef)'; Use of uninitialized value in substitution (s///) at /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level/HTML/Entities.pm
Subject: patch
Download patch
application/octet-stream 1.7k

Message body not shown because it is not plain text.

I don't get why you want to suppress the warning when you are passing input that's not conforming to the specified interface. Is there a good reason for encoding undef as undef?
Subject: Re: [rt.cpan.org #27567] suppress a warning when encode_entities is called with undef
Date: Mon, 17 Nov 2008 08:45:51 -0500
To: bug-HTML-Parser [...] rt.cpan.org
From: "Mike South" <msouth [...] gmail.com>
On Mon, Nov 17, 2008 at 6:00 AM, Gisle_Aas via RT < bug-HTML-Parser@rt.cpan.org> wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=27567 > > > I don't get why you want to suppress the warning when you are passing input > that's not > conforming to the specified interface. Is there a good reason for encoding > undef as undef?
You are already doing it. That is, you already return undef if undef is passed in: msmbp:~ msouth$ perl -MHTML::Entities -MData::Dumper -e 'print +Dumper( encode_entities(undef) )'; $VAR1 = undef; This way you do it more quietly. The alternative is for the the caller to have to either wrap their call in a no warnings pragma or call like "encode_entities( $foo || '' )" to suppress the warning. It is a very common case to have something that might be undefined, but if it is defined I want the entities in it encoded. The nice thing about this patch is that it doesn't affect old code (except to suppress a warning). The documentation does not define what happens if you pass in undef, so I don't think we would be hurting anyone. Maybe if someone had warnings fatal and wanted that warning when an undef went in, but that seems like a pretty farfetched and much less common use case than the one where you have stuff coming in that might not be defined. mike mike
I must say that I agree with Mike here. It seems like a much more common case that we don't want to see the warnings when an undef value is passed in. Any estimate as to when this patch might make it into a release?
Your patch has been applied in 3.60. Thanks.