Skip Menu |

This queue is for tickets about the News-Article CPAN distribution.

Report information
The Basics
Id: 435
Status: new
Priority: 0/
Queue: News-Article

People
Owner: Nobody in particular
Requestors: rtcpan-box [...] devin.com
Cc:
AdminCc:

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



Subject: Incorrect parsing on sources other than listrefs
News::Article's read() (and hence its constructor) incorrectly handles scalarref and coderef sources. From a scalarref, frequently only the first header is correctly parsed, the others and the body are blank. From a coderef returning an entire article on the first call and undef thereafter, the headers seem to be parsed correctly, but the body is blank. Sample code: use News::Article; @s =("Subject: sample\n", "From: foo\@bar.com\n", "To: sample\@robomoderator.tld\n", "Message-Id: <foo09238740192\@bar.tld>\n", "\n", "Body\nfoo\n"); $s = join('',@s); # scalarref approach: only first header parses correctly $a = News::Article->new(\ join('',@s)); print "$_ -> ".$a->header($_)."\n" for ('subject','from','to','message-id'); print "body => ".join("\n",$a->body)."\n---\n"; # subroutine approach: headers parsed correctly, body blank $r = sub { !$n++ ? $s : undef }; $a = News::Article->new($r ); print "$_ -> ".$a->header($_)."\n" for ('subject','from','to','message-id'); print "body => ".join("\n",$a->body)."\n---\n"; # this works, but seems to be the only way to get a correctly # parsed News::Article from a scalar: @c = map { "$_\n" } split(/\n/, $s); $a = News::Article->new(\ @c); print "$_ -> ".$a->header($_)."\n" for ('subject','from','to','message-id'); print "body => ".join("\n",$a->body)."\n";
I checked v1.26 from the author's website. This seems to fix the scalarref source problem, but not the coderef from the supplied sample code. The new version should probably be uploaded to CPAN. :)