validator/httpd/cgi-bin check,1.383,1.384

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

Modified Files:
	check 
Log Message:
Prevent XHTML output for fatals when ;output=!html. This closes Bug #749.


Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.383
retrieving revision 1.384
diff -u -d -r1.383 -r1.384
--- check	4 Feb 2005 19:25:20 -0000	1.383
+++ check	4 Feb 2005 19:44:42 -0000	1.384
@@ -567,7 +567,7 @@
 .EOF.
  }
   my $title = 'No Character Encoding Found! Falling back to UTF-8.';
-  &add_warning($File, 'fatal', $title, $message);
+  &add_warning($File, 'fallback', $title, $message);
   $File->{Tentative} |= T_ERROR; # Can never be valid.
   $File->{Charset}->{Use} = 'utf-8';
 }
@@ -1107,11 +1107,13 @@
   my $Title   = shift;
   my $Message = shift;
 
-  push @{$File->{Warnings}}, {
-                              Class   => $Class,
-                              Title   => $Title,
-                              Message => $Message,
-                             };
+  if ($File->{Mode} eq 'html' or $Class eq 'fatal') {
+    push @{$File->{Warnings}}, {
+                                Class   => $Class,
+                                Title   => $Title,
+                                Message => $Message,
+                               };
+  }
 }
 
 
@@ -1705,7 +1707,7 @@
     if ($err->{msg} =~ m(prolog can\'t be omitted)) {
       my $dtd = ($File->{Mode} == MODE_SGML ?
                    'HTML 4.01 Transitional' : 'XHTML 1.0 Transitional');
-      my $class = 'fatal';
+      my $class = 'fallback';
       my $title = "No DOCTYPE Found! Falling Back to $dtd";
       my $message = <<".EOF.";
       <p>
@@ -2887,12 +2889,24 @@
   my $Flags = shift;
 
   return unless $File->{'Error Flagged'};
+  return if $File->{'Error Message'} eq ''; # Previous error, keep going.
 
-  &prep_template($File, $E);
+  if ($File->{Output} eq 'html') {
+    &prep_template($File, $E);
 
-  $E->param(error_message => $File->{'Error Message'});
-  print $E->output;
-  exit;
+    $E->param(error_message => $File->{'Error Message'});
+    print $E->output;
+    exit;
+  } else {
+    &add_warning($File, 'fatal', 'Fatal Error', <<".EOF.");
+A fatal error has occurred while processing the requested document. Processing
+has continued but any later output will be of dubious quality. Limitations of
+this output mode prevent the full error message from being returned; please
+retry this operation in interactive mode using the web interface to see the
+actual error message.
+.EOF.
+    $File->{'Error Message'} = '';
+  }
 }
 
 #

Received on Friday, 4 February 2005 19:44:45 UTC