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

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

People
Owner:
Jeff.Fearn [...] gmail.com
Requestors:
Jeff.Fearn [...] gmail.com
Cc:
AdminCc:

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



Subject: close tag missing from optionally empty XML tags
When you add a tag to empty_element_map and it optionally contains text or other content, when the content is present the opening tag correctly has '<foo>' instead of '<foo/>', however the closing tag is missing from the text returned by as_XML. This is due to traverse not correctly validating tags as empty in the check for setting callbacks. Attached is a patch which fixes this bug. Cheers, Jeff.
Subject: missing_close_tag.patch
diff -ur HTML-Tree-3.23/lib/HTML/Element.pm HTML-Tree-3.23-fix/lib/HTML/Element.pm --- HTML-Tree-3.23/lib/HTML/Element.pm 2006-11-13 03:13:33.000000000 +1000 +++ HTML-Tree-3.23-fix/lib/HTML/Element.pm 2009-09-23 14:22:12.000000000 +1000 @@ -2041,7 +2041,7 @@ and ref($this) # sanity and not( $this->{'_empty_element'} - || $empty_element_map->{$this->{'_tag'} || ''} + || ($empty_element_map->{$this->{'_tag'} || ''} && !@{$this->{'_content'}}) ) # things that don't get post-order callbacks ) { shift @I;
Hi, here is a test script exhibiting the bug. Cheers, Jeff.
#!/usr/bin/perl -w use strict; use warnings; use HTML::Element; my $a = HTML::Element->new('a', href => 'http://example.com/'); print("Not mapped to empty element (correct)\n\t ", $a->as_XML(), "\n"); my $empty_element_map = $a->_empty_element_map; $empty_element_map->{'a'} = 1; print("Mapped to empty element, no extra content (correct)\n\t", $a->as_XML(), "\n"); $a->push_content("Extra content"); print("Mapped to empty element, extra content (missing close tag)\n\t", $a->as_XML(), "\n"); exit(0);
This patch has been applied 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.