Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37868374
en ru br
ALT Linux repos
S:5.510-alt1
5.0: 5.427-alt1
4.1: 5.420-alt1
4.0: 5.420-alt1
3.0: 5.417-alt1

Group :: Development/Perl
RPM: perl-MIME-tools

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: perl-MIME-tools-6.200_02-alt-default-charset-fallback.patch
Download


--- MIME-tools-6.200_02/lib/MIME/WordDecoder.pm-	2003-06-27 17:54:37 +0000
+++ MIME-tools-6.200_02/lib/MIME/WordDecoder.pm	2004-08-20 08:13:45 +0000
@@ -747,17 +747,8 @@
 package MIME::WordDecoder;
 
 ### Determine the default charset for this locale:
-my $DefaultCharset;
-{
-    $DefaultCharset = $ENV{LC_CTYPE} || "en_US.ISO8859-1";
-    $DefaultCharset =~ s/^\w+\.//;  ###  "en_US.ISO8859-1" => "ISO8859-1"
-    $DefaultCharset =~ s/^ISO(\w)/ISO-$1/i;
-    $DefaultCharset ||= "ISO-8859-1";   ### just in case
-}
-
 ### We now pump everything through Unicode by default.
 ### However, here's a hook for people who's Unicode support is broken.
-if ($MIME::WordDecoder::NO_UNICODE) { }
 if ($MIME::WordDecoder::NO_UNICODE) {
     
     ### Add US-ASCII handler:
@@ -772,8 +763,23 @@
     $Default = $DecoderFor{"ISO-8859-1"};
 }
 else {
-    ### Set up default:
-    $Default = MIME::WordDecoder::Unicode->new($DefaultCharset);
+	my $DefaultCharset;
+	{
+	    $DefaultCharset = $ENV{LC_CTYPE} || "en_US.ISO8859-1";
+	    $DefaultCharset =~ s/^\w+\.//;  ###  "en_US.ISO8859-1" => "ISO8859-1"
+	    $DefaultCharset =~ s/^ISO(\w)/ISO-$1/i;
+	    $DefaultCharset ||= "ISO-8859-1";   ### just in case
+	}
+
+	### Set up default:
+	eval {
+    		$Default = MIME::WordDecoder::Unicode->new($DefaultCharset);
+	};
+	if ($@) {
+		warn __PACKAGE__ . ": $@";
+		warn __PACKAGE__ . ": falling back to ISO-8859-1 (check LC_CTYPE)\n";
+    		$Default = MIME::WordDecoder::Unicode->new("ISO-8859-1");
+	}
 }
 
 #{
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin