validator/httpd/cgi-bin check,1.522,1.523

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

Modified Files:
	check 
Log Message:
bringing back line count for fatal_byte_error, output of raw decoding error message

Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.522
retrieving revision 1.523
diff -u -d -r1.522 -r1.523
--- check	18 May 2007 10:54:37 -0000	1.522
+++ check	20 May 2007 23:17:28 -0000	1.523
@@ -2049,17 +2049,20 @@
 
   # Transcoding failed
   if ($@) {
-    $File->{'Error Flagged'} = TRUE;
-
-    # @@FIXME might need better text, in particular, this does not tell
-    # where the error occured; it might be possible to emulate that
-    # using a Encode CHECK parameter that modifies the input, then split
-    # the decodable string to give line / column information, or don't
-    # split and report the offset calculated from the result.
-    $File->{Templates}->{Error}->param(fatal_byte_error   => TRUE);
-    $File->{Templates}->{Error}->param(fatal_byte_lines   => 0);
-    $File->{Templates}->{Error}->param(fatal_byte_charset => $cs);
-
+    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); };
+      if ($@) {
+        $File->{'Error Flagged'} = TRUE;
+        $File->{Templates}->{Error}->param(fatal_byte_error   => TRUE);
+        $File->{Templates}->{Error}->param(fatal_byte_lines   => $line_num);
+        $File->{Templates}->{Error}->param(fatal_byte_charset => $cs);
+        my $croak_message = $@;
+        $croak_message =~ s/ at .*//;
+        $File->{Templates}->{Error}->param(fatal_byte_error_msg => $croak_message);
+      }
+    }
     return $File;
   }
 

Received on Sunday, 20 May 2007 23:17:33 UTC