Skip Menu |

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

Report information
The Basics
Id: 49932
Status: resolved
Priority: 0/
Queue: HTML-Tree

Owner: Jeff.Fearn [...]
Requestors: Jeff.Fearn [...]

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

Subject: close tag missing from optionally empty XML tags
Download (untitled) / with headers
text/plain 403b
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/ HTML-Tree-3.23-fix/lib/HTML/ --- HTML-Tree-3.23/lib/HTML/ 2006-11-13 03:13:33.000000000 +1000 +++ HTML-Tree-3.23-fix/lib/HTML/ 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.
text/x-perl 509b
#!/usr/bin/perl -w use strict; use warnings; use HTML::Element; my $a = HTML::Element->new('a', href => ''); 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
Subject: 4.0 released
Hi HTML::Tree ve4rsion 4.0 has been released which includes a fix for this issue. Cheers, Jeff.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to