From: Kohei Yoshino Date: Fri, 22 Mar 2019 15:42:55 +0000 (-0400) Subject: Bug 1538047 - Plain text attachment cut off due to wrong charset detection (UTF-8... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=73aa0badaf5c4c9c3ff6598ad07e77dd40b25fef;p=thirdparty%2Fbugzilla.git Bug 1538047 - Plain text attachment cut off due to wrong charset detection (UTF-8 as Windows-1252) --- 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; }