From 73aa0badaf5c4c9c3ff6598ad07e77dd40b25fef Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Fri, 22 Mar 2019 11:42:55 -0400 Subject: [PATCH] Bug 1538047 - Plain text attachment cut off due to wrong charset detection (UTF-8 as Windows-1252) --- Bugzilla/Util.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 128642f0b..a59ba5d02 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -913,6 +913,12 @@ sub detect_encoding { $encoding = $decoded_as if $decoded_as; } + # Encode::Detect sometimes mis-detects UTF-8 as Windows-1252 + if ($encoding && $encoding eq 'cp1252') { + my $decoder = guess_encoding($data, ('utf8', 'cp1252')); + $encoding = $decoder->name if ref $decoder; + } + return $encoding; } -- 2.47.3