- From: Ville Skytta <ville@dev.w3.org>
- Date: Sun, 09 Jan 2005 11:24:36 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin In directory hutz:/tmp/cvs-serv1480/httpd/cgi-bin Modified Files: check Log Message: transcode(): don't output 'The error was "".', instantiate only one Text::Iconv, clean up code and rephrase messages a bit. http://www.w3.org/Bugs/Public/show_bug.cgi?id=981 Index: check =================================================================== RCS file: /sources/public/validator/httpd/cgi-bin/check,v retrieving revision 1.366 retrieving revision 1.367 diff -u -d -r1.366 -r1.367 --- check 8 Jan 2005 22:18:05 -0000 1.366 +++ check 9 Jan 2005 11:24:33 -0000 1.367 @@ -2314,33 +2314,34 @@ sub transcode { my $File = shift; + my $cs = $File->{Charset}->{Use}; my ($command, $result_charset) = ('', ''); - if ($CFG->{Charsets}->{$File->{Charset}->{Use}}) { - ($command, $result_charset) = - split(" ", $CFG->{Charsets}->{$File->{Charset}->{Use}}, 2); + if ($CFG->{Charsets}->{$cs}) { + ($command, $result_charset) = split(" ", $CFG->{Charsets}->{$cs}, 2); } + my $c; $result_charset = exact_charset($File, $result_charset); + if ($command eq 'I') { # test if given charset is available - eval {my $c = Text::Iconv->new($result_charset, 'utf-8')}; + eval { $c = Text::Iconv->new($result_charset, 'utf-8') }; $command = '' if $@; } elsif ($command eq 'X') { $@ = "$File->{Charset}->{Use} undefined; replace by $result_charset"; } if ($command ne 'I') { - my $cs = &ent($File->{Charset}->{Use}); + my $error = $@ ? sprintf('<p>The error was: "%s".</p>', &ent($@)) : ''; $File->{'Error Flagged'} = TRUE; - $File->{'Error Message'} = sprintf(<<".EOF.", $cs, &ent($@)); + $File->{'Error Message'} = sprintf(<<".EOF.", &ent($cs), $error); <p>Sorry! A fatal error occurred when attempting to transcode the character encoding of the document. Either we do not support this character - encoding yet, or you have specified a non-existent character encoding - (often a misspelling). + encoding ("%s") yet, or you have specified a non-existent character + encoding (often a misspelling). </p> - <p>The detected character encoding was "%s".</p> - <p>The error was "%s".</p> + %s <p> If you believe the character encoding to be valid you can submit a request for that character encoding (see the @@ -2352,7 +2353,6 @@ return $File; } - my $c = Text::Iconv->new($result_charset, 'utf-8'); my $line = 0; for (@{$File->{Content}}) { my $in = $_; @@ -2374,7 +2374,7 @@ } my $remain = (length $in) - $short; $_ = $c->convert(substr($in,0,$short)) - . "#### $remain byte(s) unconvertable ####"; + . "#### $remain byte(s) unconvertible ####"; } } return $File;
Received on Sunday, 9 January 2005 11:24:36 UTC