Skip Menu |
 

This queue is for tickets about the Text-WikiFormat CPAN distribution.

Report information
The Basics
Id: 1455
Status: resolved
Worked: 45 min
Priority: 0/
Queue: Text-WikiFormat

People
Owner: chromatic [...] cpan.org
Requestors: deus_x [...] pobox.com
Cc:
AdminCc:

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



MIME-Version: 1.0
X-Mailer: MIME-tools 5.405 (Entity 5.404)
Subject: Error when text has leading newlines
Content-Type: multipart/mixed; boundary="----------=_1029719552-19362-11"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 383
Download (untitled) / with headers
text/plain 383b
I tried to format text which began with newlines and received the following error: Can't use an undefined value as an ARRAY reference at /home/deusx/lib/perl/Text/WikiFormat.pm line 142. This is what I did to fix it: 142c142 < return '' unless @{ $lists->{$active} }; --- Show quoted text
> return '' unless ( (ref($lists->{$active}) eq 'ARRAY') && @{ $lists->{$active} } );
Cheers :)
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
MIME-Version: 1.0
X-Mailer: MIME-tools 5.405 (Entity 5.404)
Content-Type: multipart/mixed; boundary="----------=_1030232044-3792-3"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 462
Download (untitled) / with headers
text/plain 462b
[DEUSX - Sun Aug 18 21:12:32 2002]: Show quoted text
> This is what I did to fix it: > > 142c142 > < return '' unless @{ $lists->{$active} }; > ---
> > return '' unless ( (ref($lists->{$active}) eq 'ARRAY') && @{
> $lists->{$active} } );
That's a genuine bug indeed. I think a better solution is not to call end_list() if there is no active list. Please try the attached patch and see if that cures it. (It works with my test case.) Thanks for the report, -- c
Content-Type: application/octet-stream; name="listend.patch"
Content-Disposition: inline; filename="listend.patch"
Content-Transfer-Encoding: base64
Content-Length: 1155
Download listend.patch
text/x-diff 1.1k
--- lib/Text/WikiFormat.pm~ Sat Aug 24 16:25:38 2002 +++ lib/Text/WikiFormat.pm Sat Aug 24 16:25:43 2002 @@ -121,7 +121,7 @@ if ($active_list and $active_list ne 'paragraph' or !$line) { pop @{ $lists{paragraph} } unless $line; $parsed .= end_list(\%lists, $active_list, - $tags{$active_list}); + $tags{$active_list}) if @{ $lists{paragraph} }; } next unless $line; --- /dev/null Thu Aug 30 02:54:37 2001 +++ t/bugs.t Sat Aug 24 16:29:56 2002 @@ -0,0 +1,21 @@ +#!/usr/bin/perl -w + +use strict; + +BEGIN { + chdir 't' if -d 't'; + unshift @INC, '../lib'; +} + +use Test::More tests => 2; + +use_ok( 'Text::WikiFormat' ); + +my $wikitext =<<WIKI; + +'''hello''' +WIKI + +my $htmltext = eval { Text::WikiFormat::format($wikitext) }; +is( $@, '', + 'format() should throw no warnings for text starting with newlines' );
MIME-Version: 1.0
X-Mailer: MIME-tools 5.405 (Entity 5.404)
From: kake [...] earth.li
Content-Type: multipart/mixed; boundary="----------=_1030957747-6686-0"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 310
Download (untitled) / with headers
text/plain 310b
[CHROMATIC - Sat Aug 24 19:34:04 2002]: Show quoted text
> Please try the attached patch and see if that cures it. (It works > with my test case.)
Your patch seems to introduce another bug which stops lists that are followed by paragraphs from being included in the formatted input. Different patch and test attached. Kake
Content-Type: application/octet-stream; name="listend2.patch"
Content-Disposition: inline; filename="listend2.patch"
Content-Transfer-Encoding: base64
Content-Length: 1447
Download listend2.patch
text/x-diff 1.4k
--- lib/Text/WikiFormat.pm~ 2002-09-02 09:49:22.000000000 +0100 +++ lib/Text/WikiFormat.pm 2002-09-02 09:50:32.000000000 +0100 @@ -121,7 +121,7 @@ sub format { if ($active_list and $active_list ne 'paragraph' or !$line) { pop @{ $lists{paragraph} } unless $line; $parsed .= end_list(\%lists, $active_list, - $tags{$active_list}); + $tags{$active_list}) if $active_list; } next unless $line; --- /dev/null 2002-07-30 14:27:09.000000000 +0100 +++ t/bugs.t 2002-09-02 09:56:24.000000000 +0100 @@ -0,0 +1,29 @@ +#!/usr/bin/perl -w + +use strict; + +BEGIN { + chdir 't' if -d 't'; + unshift @INC, '../lib'; +} + +use Test::More tests => 3; + +use_ok( 'Text::WikiFormat' ); + +my $wikitext =<<WIKI; + + + * unordered + +Final paragraph. + +WIKI + +my $htmltext = eval { Text::WikiFormat::format($wikitext) }; + +is( $@, '', + 'format() should throw no warnings for text starting with newlines' ); + +like( $htmltext, qr!<li>unordered</li>!, + 'ensure that lists followed by paragraphs are included correctly' );
MIME-Version: 1.0
X-Mailer: MIME-tools 5.405 (Entity 5.404)
Content-Type: multipart/mixed; boundary="----------=_1031854392-3693-6"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 262
Download (untitled) / with headers
text/plain 262b
[guest - Mon Sep 2 05:09:07 2002]: Show quoted text
> Your patch seems to introduce another bug which stops lists that are > followed by paragraphs from being included in the formatted input. > Different patch and test attached.
Thanks, applied! This will be in version 0.45.
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.