From 234c8d165747751e5be4abe620aa31d55ba569e2 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Fri, 18 Feb 2011 15:07:46 -0700 Subject: [PATCH] Use HTML::Entities to decode the entities in the response. --- modules/LinkTitle.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/LinkTitle.pm b/modules/LinkTitle.pm index 41a34d0..688e604 100644 --- a/modules/LinkTitle.pm +++ b/modules/LinkTitle.pm @@ -5,6 +5,7 @@ package M::LinkTitle; use strict; use warnings; use LWP::UserAgent; +use HTML::Entities; use API::Std qw(hook_add hook_del); use API::IRC qw(privmsg); @@ -52,8 +53,10 @@ sub gettitle # Check for if ($data =~ m{<title>(.*)}ixsm) { - # Found. Return it to channel. - privmsg($src->{svr}, $chan, "\2Title:\2 $1"); + # Found. Decode it. + my $title = decode_entities($1); + # Return to channel. + privmsg($src->{svr}, $chan, "\2Title:\2 $title"); } } } @@ -65,7 +68,7 @@ sub gettitle # Start initialization. API::Std::mod_init('LinkTitle', 'Xelhua', '1.00', '3.0.0a5', __PACKAGE__); # vim: set ai sw=4 ts=4: -# build: cpan=LWP::UserAgent perl=5.010000 +# build: cpan=LWP::UserAgent,HTML::Entities perl=5.010000 __END__ @@ -90,7 +93,7 @@ detected, Auto will connect to it and get the page title by scanning for the =head1 DEPENDENCIES -This module is dependent on one module from the CPAN. +This module is dependent on two modules from the CPAN. =over @@ -98,6 +101,11 @@ This module is dependent on one module from the CPAN. This module is used for connecting to the target web server via HTTP(S). +=item L + +This module is used for decoding HTML entities in the response we receive from +the server. + =back =head1 AUTHOR