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

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

People
Owner:
Nobody in particular
Requestors:
bokutin [...] cpan.org
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
4.2
Fixed in:
5.03



Subject: textarea broken by $root->as_HTML( .., ' ' ) indentation.
Hi. I used CSS::Inliner. CSS::Inliner depend HTML::Tree. I occurred <textarea> broken. I found a bug and fixed and wrote test bit. Please merge this patch. Cheers Tomohiro Hosaka
Subject: bug_textarea.txt
diff -ru HTML-Tree-4.2.orig/lib/HTML/Element.pm HTML-Tree-4.2/lib/HTML/Element.pm --- HTML-Tree-4.2.orig/lib/HTML/Element.pm 2011-04-06 17:37:54.000000000 +0900 +++ HTML-Tree-4.2/lib/HTML/Element.pm 2011-08-21 06:31:36.000000000 +0900 @@ -1583,7 +1583,7 @@ $last_tag_tightenable = $this_tag_tightenable; ++$nonindentable_ancestors - if $tag eq 'pre' + if $tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag}; } @@ -1594,7 +1594,7 @@ { # on the way out - if ( $tag eq 'pre' + if ( $tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag} ) { --$nonindentable_ancestors; diff -ru HTML-Tree-4.2.orig/t/body.t HTML-Tree-4.2/t/body.t --- HTML-Tree-4.2.orig/t/body.t 2011-04-06 17:37:54.000000000 +0900 +++ HTML-Tree-4.2/t/body.t 2011-08-21 06:30:34.000000000 +0900 @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 11; +use Test::More tests => 13; BEGIN { use_ok('HTML::TreeBuilder'); @@ -89,3 +89,12 @@ "<html><head></head><body><b>\$self->escape</b></body></html>" ) ; # 3.22 compatability } + +NO_INDENT_PRE_AND_TEXTAREA: { + my $root = HTML::TreeBuilder->new(); + my $pre = '<pre></pre>'; + my $textarea = '<textarea></textarea>'; + my $html = $root->parse_content("<html><head></head><body>$pre$textarea</body></html>"); + like( $html->as_HTML(), qr/$pre.*$textarea/ ); + like( $html->as_HTML( undef, " " ), qr/$pre.*$textarea/ ); +}
I've merged this as https://github.com/madsen/HTML-Tree/commit/466ece91fd6b829515f568871b1ecf8fe41fc329 (except for the tests, which I rewrote) and just released 5.03 to CPAN. Sorry it took so long, but I overlooked this when I was looking for fixes to apply. It helps if you include PATCH in the subject (or send a pull request on GitHub).
Thank you very much!!


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.