summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorot <ot@localhost>2007-05-20 23:17:29 +0000
committerot <ot@localhost>2007-05-20 23:17:29 +0000
commit1facb9c8155a1e7a30fd6dffd8d31bce14598ad2 (patch)
treeda035427bb809f42f98bf2f5afae188876bf3954
parentadcb84494bc44caa7d26c2f4b57d96d991b74e3b (diff)
downloadmarkup-validator-1facb9c8155a1e7a30fd6dffd8d31bce14598ad2.zip
markup-validator-1facb9c8155a1e7a30fd6dffd8d31bce14598ad2.tar.gz
markup-validator-1facb9c8155a1e7a30fd6dffd8d31bce14598ad2.tar.bz2
bringing back line count for fatal_byte_error, output of raw decoding error message
-rwxr-xr-xhttpd/cgi-bin/check29
-rw-r--r--share/templates/en_US/fatal-error.tmpl3
2 files changed, 19 insertions, 13 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check
index 9ba6e77..ba2690d 100755
--- a/httpd/cgi-bin/check
+++ b/httpd/cgi-bin/check
@@ -14,7 +14,7 @@
# This source code is available under the license at:
# http://www.w3.org/Consortium/Legal/copyright-software
#
-# $Id: check,v 1.522 2007-05-18 10:54:37 ville Exp $
+# $Id: check,v 1.523 2007-05-20 23:17:28 ot Exp $
#
# Disable buffering on STDOUT!
@@ -181,7 +181,7 @@ Directory not readable (permission denied): @_r
#
# Strings
- $VERSION = q$Revision: 1.522 $;
+ $VERSION = q$Revision: 1.523 $;
$VERSION =~ s/Revision: ([\d\.]+) /$1/;
#
@@ -2049,17 +2049,20 @@ sub transcode {
# 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;
}
diff --git a/share/templates/en_US/fatal-error.tmpl b/share/templates/en_US/fatal-error.tmpl
index 79789e7..684f6ef 100644
--- a/share/templates/en_US/fatal-error.tmpl
+++ b/share/templates/en_US/fatal-error.tmpl
@@ -41,6 +41,9 @@
Character Encoding). Please check both the content of the file and the
character encoding indication.
</p>
+ <p>The error was:
+ <TMPL_VAR NAME="fatal_byte_error_msg">
+ </p>
</li>
</TMPL_IF>