Subject: | XML::Twig::Elt->set_content fails when argument is 'XML::Twig::Elt' |
The XML::Twig::Elt->set_content() method checks whether its argument is
already an element by testing whether (isa( $_[0], 'XML::Twig::Elt')) .
Unfortunately, if $_[0] is the actual string 'XML::Twig::Elt' (or the
exact name of some subclass of XML::Twig::Elt, which is how I discovered
it [subclass 'Line', oops]), then many of the internal assumptions are
violated and XML::Parser will crash deeper in.
I have attached two files:
* a new test case that replicates the bug
* a patch for the bug (I named it test_3_33; feel free to rename of course).
Please patch and release soon so I can use the distribution version of
this code again (rather than my own patches!).
--Jeremy
Subject: | xml-twig-ref-error-crasher.patch |
Only in XML-Twig-3.33-jgk/t: test_3_33.t
diff --unified --recursive XML-Twig-3.33/Twig.pm XML-Twig-3.33-jgk/Twig.pm
--- XML-Twig-3.33/Twig.pm 2008-10-26 16:45:40.000000000 -1000
+++ XML-Twig-3.33-jgk/Twig.pm 2008-10-26 16:53:49.000000000 -1000
@@ -8341,7 +8341,7 @@
{ $child->delete; }
foreach my $child (@_)
- { if( isa( $child, 'XML::Twig::Elt'))
+ { if( ref $child and isa( $child, 'XML::Twig::Elt'))
{ # argument is an element
$child->paste( 'last_child', $elt);
}
diff --unified --recursive XML-Twig-3.33/Twig_pm.slow XML-Twig-3.33-jgk/Twig_pm.slow
--- XML-Twig-3.33/Twig_pm.slow 2008-10-14 00:45:01.000000000 -1000
+++ XML-Twig-3.33-jgk/Twig_pm.slow 2008-10-26 16:53:30.000000000 -1000
@@ -8344,7 +8344,7 @@
{ $child->delete; }
foreach my $child (@_)
- { if( isa( $child, 'XML::Twig::Elt'))
+ { if( ref $child and isa( $child, 'XML::Twig::Elt'))
{ # argument is an element
$child->paste( 'last_child', $elt);
}
Only in XML-Twig-3.33-jgk/: Twig_pm.slow~
Subject: | test_3_33.t |
#!/usr/bin/perl -w
use strict;
# $Id: /xmltwig/trunk/t/test_3_30.t 27 2007-08-30T08:07:25.079327Z mrodrigu $
use strict;
use Carp;
use File::Spec;
use lib File::Spec->catdir(File::Spec->curdir,"t");
use tools;
$|=1;
my $DEBUG=0;
use XML::Twig;
my $TMAX=1;
print "1..$TMAX\n";
my $tok = XML::Twig::Elt->new(foo => {} => 'XML::Twig::Elt');
ok (defined $tok and $tok->isa('XML::Twig::Elt'), 'created an token with classname in text element');
exit 0;
1;