Skip Menu |
 

This queue is for tickets about the XML-Generator-PerlData CPAN distribution.

Report information
The Basics
Id: 55331
Status: new
Priority: 0/
Queue: XML-Generator-PerlData

People
Owner: Nobody in particular
Requestors: michael [...] zedeler.dk
Cc:
AdminCc:

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



Subject: Circular references causes the module to crash
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1268048174-12695-111"
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 212
Download (untitled) / with headers
text/plain 212b
This module doesn't handle circular references. I'd suggest silently ignoring them by skipping any reference that has been processed before. One could make this behaviour optional. See attached test and patch.
Subject: PerlData.pm.patch
MIME-Version: 1.0
Content-Type: text/x-patch; name="PerlData.pm.patch"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="PerlData.pm.patch"
Content-Transfer-Encoding: binary
Content-Length: 1604
Download PerlData.pm.patch
text/x-diff 1.5k
*** /tmp/XML-Generator-PerlData-0.91/PerlData.pm 2007-08-04 14:57:00.000000000 +0200 --- PerlData.pm 2010-03-08 12:12:51.000000000 +0100 *************** *** 4,9 **** --- 4,10 ---- use XML::SAX::Base; use vars qw($VERSION @ISA $NS_XMLNS $NS_XML); use Data::Dumper; + use Scalar::Util qw(refaddr); # some globals $VERSION = '0.91'; @ISA = qw( XML::SAX::Base ); *************** *** 47,52 **** --- 48,54 ---- $self->{RootName} ||= 'document'; $self->{DefaultElementName} ||= 'default'; $self->{TokenReplacementChar} ||= '_'; + $self->{Seen} ||= {}; if ( defined $args{namespaces} ) { foreach my $uri ( keys( %{$args{namespaces}} )) { *************** *** 162,167 **** --- 164,178 ---- } } + # Check if we have visited a given reference before + sub circular { + my($self, $ref) = @_; + my $addr = refaddr($ref); + my $result = $self->{Seen}->{$addr}; + $self->{Seen}->{$addr} = 1; + return $result; + } + sub hashref2SAX { my $self = shift; *************** *** 169,174 **** --- 180,187 ---- my $char_data = ''; + return if $self->circular($hashref); + ELEMENT: foreach my $key (keys (%{$hashref} )) { my $value = $hashref->{$key}; my $element_name = $self->_keymapped_name( $key ); *************** *** 233,238 **** --- 246,253 ---- my $passed_name = shift || $self->{_Parents}->[-1]; my $temp_name = $self->_keymapped_name( $passed_name ); + return if $self->circular($arrayref); + my $element_name; my $i;
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2913-1277171822-320.55331-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: michael [...] zedeler.dk
X-RT-Original-Encoding: utf-8
Content-Length: 395
Download (untitled) / with headers
text/plain 395b
On Mon Mar 08 06:36:20 2010, mzedeler wrote: Show quoted text
> This module doesn't handle circular references. > > I'd suggest silently ignoring them by skipping any reference that has > been processed before. One could make this behaviour optional. > > See attached test and patch.
I have forked XML::Generator::PerlData at github: http://github.com/mzedeler/XML-Generator-PerlData Currently version 0.92.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-2913-1277171822-320.55331-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-2913-1277171822-320.55331-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2912-1277172920-1887.55331-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: michael [...] zedeler.dk
X-RT-Original-Encoding: utf-8
Content-Length: 671
Download (untitled) / with headers
text/plain 671b
On Mon Jun 21 21:57:02 2010, mzedeler wrote: Show quoted text
> On Mon Mar 08 06:36:20 2010, mzedeler wrote:
> > This module doesn't handle circular references. > > > > I'd suggest silently ignoring them by skipping any reference that has > > been processed before. One could make this behaviour optional. > > > > See attached test and patch.
> > I have forked XML::Generator::PerlData at github: > > http://github.com/mzedeler/XML-Generator-PerlData > > Currently version 0.92.
Sorry - wrong descision. I have forked the already existing repository at github. The correct URL is: http://github.com/mzedeler/xml-generator-perldata And the version you'll find there is still 0.91.


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.