|
|
Choosing A Webhost: |
Re: Possible bug in HTML::Parser version 3.48: msg#00002lang.perl.modules.lwp
Jack Goldstein <jackg@xxxxxxxxxx> writes: > I've installed HTML::Parser on an AIX 5.1 system running perl 5.8.6 along > with HTML::Tagset and all tests passed except for one relating to POD that > was skipped. However, one of our developers found that it didn't properly > parse titles. Here's a sample program that demonstrates the problem. When > run with the perl 5.8.6 that I installed, the output is > > Help Title is > (blank line) > > but when when run with a copy of perl5.8.0 that someone else installed, we > get: > > Help Title is Installation Help > > which I assume is correct. Thanks for your bug report. This is indeed a bug. Its cause is that some events would trigger under certain circumstances even after a handler has told the parser to stop with $p->eof. I've now fixed this issue and uploaded HTML-Parser-3.49 to CPAN. My guess would be that your perl5.8.0 installation has a version of HTML-Parser that is older than version 3.40, where we made <title> tags also parse in literal mode. This could explain why this issue didn't occur with that perl installation. > use HTML::Parser; > > my $title=''; > > my $p = HTML::Parser->new(api_version => 3,); > $p->handler(start=> \&title_handler, 'tagname, self'); > $p->parse_file("db2wi.htm"); > print "\nHelp Title is $title\n"; > exit 0; > > ######################################## > # Subroutines > ######################################## > sub title_handler { > return if shift ne 'title'; > my $self = shift; > $self->handler(text => sub { $title= shift}, 'dtext'); BTW, HTML-Parser does not guarantee that all text between the <title>...</title> tags are reported in a single callback, which means this code should append to $title instead of just assigning to it. That would make it: $self->handler(text => sub { $title .= shift}, 'dtext'); Alternatively, set the 'unbroken_text' attribute to a TRUE value. > $self->handler(end => sub { shift->eof if shift eq 'title' }, 'tagname, > self'); > } Regards, Gisle
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Possible bug in HTML::Parser version 3.48, Jack Goldstein |
|---|---|
| Next by Date: | Authenticating with Apache htaccess, Eric Langheinrich |
| Previous by Thread: | Possible bug in HTML::Parser version 3.48, Jack Goldstein |
| Next by Thread: | Authenticating with Apache htaccess, Eric Langheinrich |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |