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

Report information
The Basics
Id:
36247
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Jeff.Fearn [...] gmail.com
Requestors:
colin.fine [...] pace.co.uk
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
3.23
Fixed in:
(no value)



Subject: HTML::Element broken when passing a subclassed object to new_from_lol
If you subclass HTML::Element, and then pass an object of the subclass to new_from_lol (or push_content) inside an ARRAYREF, it crashes out with Can't use string ("1") as a HASH ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.5/HTML/Element.pm line 905. The problem is that line 3393 (in the anonymous sub inside new_from_lol) it claims unowned elements by setting their _parent property to 1, relying on line 3413 to correct this illegal situation. But 3413 is inside the condition "if($class eq __PACKAGE__)" - so if the element is not of class HTML::Element, but a derived class, it misses this code and leaves the invalid '1' in the parent properties. Example code: #! /usr/bin/perl -w use HTML::Element; my $div1 = new HTML::Element('div'); $div1->push_content('Contents of div1'); my $mydiv = new MyElement('div'); $mydiv->push_content( ['div', $div1] ); package MyElement; use base 'HTML::Element'; sub new { my $invoker = shift; my $class = ref $invoker || $invoker; return $class->SUPER::new(@_); } ===================================================== It seems to me that a fix is to replace line 3418 $node->push_content(@children) if @children; by $node->push_content( map {$_->{'_parent'} = $node if ref $_; $_} @children) if @children; [Fedora 7, Perl 5.8.5, but I don't believe these are relevant] Colin Fine Engineering Tools Group Pace plc
My line numbers are a little adrift in the previous message - I forgot that I had already applied a fix for RT 24948 in my local copy. Colin Fine
Applied provided fix to http://github.com/jfearn/HTML-Tree
Subject: 4.0 released
Hi HTML::Tree ve4rsion 4.0 has been released which includes a fix for this issue. Cheers, Jeff.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

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