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

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

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



Subject: close tag missing from optionally empty XML tags
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1253681258-2295-236"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 403
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
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1253681258-2295-235"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: text/x-patch; name="missing_close_tag.patch"
Content-Disposition: inline; filename="missing_close_tag.patch"
Content-Transfer-Encoding: binary
Content-Length: 609
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;
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
Content-Type: multipart/mixed; boundary="----------=_1253832682-2295-338"
Message-ID: <rt-3.6.HEAD-2295-1253832682-1870.49932-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 60
Hi, here is a test script exhibiting the bug. Cheers, Jeff.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1253832682-2295-337"
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: application/x-perl; name="test.pl"
Content-Disposition: inline; filename="test.pl"
Content-Transfer-Encoding: base64
Content-Length: 509
Download test.pl
text/x-perl 509b
#!/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);
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-26545-1272085326-218.49932-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 65
This patch has been applied to http://github.com/jfearn/HTML-Tree
MIME-Version: 1.0
Subject: 4.0 released
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-24885-1285123079-418.49932-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 96
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 Perl.org infrastructure.

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