]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1538047 - Plain text attachment cut off due to wrong charset detection (UTF-8...
authorKohei Yoshino <kohei.yoshino@gmail.com>
Fri, 22 Mar 2019 15:42:55 +0000 (11:42 -0400)
committerGitHub <noreply@github.com>
Fri, 22 Mar 2019 15:42:55 +0000 (11:42 -0400)
Bugzilla/Util.pm

index 128642f0b344d41cbeca33fcd5fee4dbfd460aef..a59ba5d02ff1654f3a78cd92f9c5ccd2462ce260 100644 (file)
@@ -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;
 }