validator/httpd/cgi-bin check,1.713,1.714

Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv9482

Modified Files:
	check 
Log Message:
Avoid some charset encoder lookups.

Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.713
retrieving revision 1.714
diff -u -d -r1.713 -r1.714
--- check	23 Oct 2009 19:09:44 -0000	1.713
+++ check	23 Oct 2009 19:18:00 -0000	1.714
@@ -2680,9 +2680,9 @@
   }
 
   # Does the system support decoding this encoding?
-  eval { Encode::decode($cs, ''); };
+  my $enc = Encode::find_encoding($cs);
 
-  if ($@) {
+  if (!$enc) {
     # This system's Encode installation does not support
     # the character encoding; might need additional modules
 
@@ -2708,15 +2708,17 @@
 
   # Try to transcode
   eval {
-    $output = Encode::decode($cs, $input, Encode::FB_CROAK);
+    $output = $enc->decode($input, Encode::FB_CROAK);
   };
 
-  # Transcoding failed
   if ($@) {
+    # Transcoding failed - do it again line by line to find out exactly where
     my $line_num = 0;
     foreach my $input_line (split /\r\n|\n|\r/, $input) {
       $line_num++;
-      eval { Encode::decode($cs, $input_line, Encode::FB_CROAK); };
+      eval {
+        $enc->decode($input_line, Encode::FB_CROAK);
+      };
       if ($@) {
         my $croak_message = $@;
         $croak_message =~ s/ at .*//;

Received on Friday, 23 October 2009 19:18:06 UTC