From 892c385e04880f723567b3611eb945093f1eed8b Mon Sep 17 00:00:00 2001
From: David Phillips <david@sighup.nz>
Date: Sun, 29 Sep 2019 13:30:29 +1300
Subject: URL_Title: clear globals before parsing

This patch prevents accidental leakage of content-type header and charset
between calls to get_title. Without clearing these, it is possible for a URL
title to be decoded from the wrong charset if a URL was previously titled
with a differing charset to the current one. This patch clears these stale
values to guarantee accurate charset decoding per URL.
---
 Plugin/URL_Title.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Plugin/URL_Title.pm b/Plugin/URL_Title.pm
index 14b963d..d787d90 100644
--- a/Plugin/URL_Title.pm
+++ b/Plugin/URL_Title.pm
@@ -88,7 +88,9 @@ sub get_title
 
 	my $html = $response->{content};
 
-	$title = "";
+	$charset = undef;
+	$content_type = undef;
+	$title = undef;
 	my $p = HTML::Parser->new(api_version => 3);
 	$p->handler( start => \&start_handler, "tagname,attr,self" );
 	$p->parse($html);
-- 
cgit v1.1