Skip Menu |

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

Report information
The Basics
Id: 70927
Status: open
Priority: 0/
Queue: HTML-Defang

People
Owner: Nobody in particular
Requestors: Prabhudhan [...] aol.com
Cc:
AdminCc:

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



Subject: Small bug in defang
Date: Tue, 13 Sep 2011 10:19:41 -0400 (EDT)
To: bug-HTML-Defang [...] rt.cpan.org
From: Prabhudhan [...] aol.com
When I input the string "0", nothing comes out. Perl version: Activestate 5.12.4 build 1205 HTML-Defang version 1.04 OS: Windows XP example code: use HTML::Defang; my $Defang = HTML::Defang->new(); print $Defang->defang("0");
From: spamthis [...] sogetthis.com
I also ran into this and saw there was already the above report. Some more info to reproduce: #!/usr/bin/perl use HTML::Defang; use strict; use warnings; print "HTML::Defang Version $HTML::Defang::VERSION\n"; my $Defang = HTML::Defang->new(); print "Result -> '".$Defang->defang($_)."'\n" foreach ( 0, 00, '0', '00' ); __END__ Output is: HTML::Defang Version 1.04 Result -> '' Result -> '' Result -> '' Result -> '00'
attached patch with test
Subject: 0001-fix-tests-for-70927.patch
From e0c1e3493f022231889dd41f48652def24a6ae8f Mon Sep 17 00:00:00 2001 From: Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> Date: Wed, 3 Jun 2020 09:59:37 +0100 Subject: [PATCH] fix & tests for #70927 --- lib/HTML/Defang.pm | 2 +- t/01_basic.t | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/HTML/Defang.pm b/lib/HTML/Defang.pm index 8520e56..60af9b1 100644 --- a/lib/HTML/Defang.pm +++ b/lib/HTML/Defang.pm @@ -1416,7 +1416,7 @@ sub defang { warn "defang OutputRemainder" if $Debug; $I =~ m/\G(.*)$/gcs; - $$OutR .= $1 if $1; + $$OutR .= $1 if defined $1; # Exit if we got here last; diff --git a/t/01_basic.t b/t/01_basic.t index 7759011..9d96ee5 100755 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -4,7 +4,7 @@ BEGIN { # CPAN users don't have ME::*, so use eval eval 'use ME::FindLibs' } -use Test::More tests => 93; +use Test::More tests => 98; use HTML::Defang; use strict; @@ -13,6 +13,21 @@ my ($DefangString, $CommentStartText, $CommentEndText) = ('defang_', '/\*SC\*/', my $Defang = HTML::Defang->new(); +$H = ''; $Res =$Defang->defang($H); +is($Res, '', 'empty string should stay as-is'); + +$H = ' '; $Res =$Defang->defang($H); +is($Res, ' ', 'whitespace should stay as-is'); + +$H = '0'; $Res =$Defang->defang($H); +is($Res, '0', 'zero-as-a-string should stay as-is'); + +$H = '00'; $Res =$Defang->defang($H); +is($Res, '00', 'zero-zero should stay as-is'); + +$H = 0; $Res =$Defang->defang($H); +is($Res, '0', 'zero-as-a-number (weird) should stay as-is'); + $H = <<EOF; 1:<html> 2:<head> -- 2.26.2