PhilterPaper / HTML-Tree

HTML tree handling modules for Perl
0 stars 0 forks source link

Uninitialized values reported by HTML-TreeBuilder and HTML-Element #1

Open PhilterPaper opened 4 months ago

PhilterPaper commented 4 months ago

HTML-Tree 2 https://github.com/kentfredric/HTML-Tree/issues/2 reported by @XXstack, with replies by @kentfredric and @gregoa.

Test case from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901732

#!/usr/bin/perl

use 5.010;
use strict;
use warnings;

use HTML::TableExtract qw<tree>;

my $html = <<__EOS__;
<!DOCTYPE html>
<head><title>a title</title>
<body>
<table><tr><td>1</td></td></tr></table>
</body>
</html>
__EOS__

my $te = HTML::TableExtract->new;
$te->parse ($html);

Requires installation of HTML::TableExtract and HTML::ElementTable.

Output:

Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 341.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 349.
Use of uninitialized value in string eq at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1670.
Use of uninitialized value in string eq at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1670.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1677.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1180.
Use of uninitialized value $ptag in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1206.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1677.
Use of uninitialized value in concatenation (.) or string at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1317.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 341.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 349.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1180.
Use of uninitialized value $ptag in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1206.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1677.
Use of uninitialized value in concatenation (.) or string at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1317.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 341.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 349.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 464.
Use of uninitialized value $ptag in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 468.
Use of uninitialized value in string eq at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1670.
Use of uninitialized value in string eq at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1670.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1677.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1677.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1180.
Use of uninitialized value $ptag in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1206.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1677.
Use of uninitialized value in concatenation (.) or string at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1317.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1071.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1180.
Use of uninitialized value $ptag in hash element at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1206.
Use of uninitialized value in hash element at C:/Strawberry/perl/vendor/lib/HTML/Element.pm line 1677.
Use of uninitialized value in concatenation (.) or string at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1317.
Use of uninitialized value $ptag in string eq at C:/Strawberry/perl/vendor/lib/HTML/TreeBuilder.pm line 1071.
PhilterPaper commented 4 months ago

Here's what I've found so far. With qw<tree>, a bunch of uninitialized value errors, without it, no errors reported (who knows if the code does what is intended, but no error messages).

So, what is SUPER::parse()? The only parse() I can find is in TableExtract.pm (none in HTML::Tree family). HTML::Form has a parse(), but it does not appear to be called. Until I can find who this SUPER::parse() is, I'm stuck. I presume that if I can find this parse(), it will eventually lead me to some TreeBuilder and Element calls with bad parameters or something. There are a couple of sub trees in TableExtract, and my understanding of use...qw<list> is that it spells out which version of the list names to use, in some fashion (but I admit I'm weak in this area). I also tried qw(tree) with no apparent difference, in case the angle-brackets versus parentheses made any difference.