summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xhttpd/cgi-bin/check40
-rw-r--r--share/templates/en_US/fatal-error.tmpl15
-rw-r--r--share/templates/en_US/soap_fault.tmpl17
3 files changed, 67 insertions, 5 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check
index 03d1f2b..c4e45d3 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.657 2009-06-23 17:59:48 ville Exp $
+# $Id: check,v 1.658 2009-06-23 18:08:21 ville Exp $
#
# Disable buffering on STDOUT!
$| = 1;
@@ -199,7 +199,7 @@ Directory not readable (permission denied): @_r
#
# Strings
- $VERSION = q$Revision: 1.657 $;
+ $VERSION = q$Revision: 1.658 $;
$VERSION =~ s/Revision: ([\d\.]+) /$1/;
#
@@ -915,7 +915,9 @@ sub compoundxml_validate (\$) {
$File->{Templates}->{Error}->param(fatal_missing_checker => "HTML5 Validator");
}
else {
- my $content = $res->decoded_content(charset => 'none');
+ my $content = &get_content($File, $res);
+ return $File if $File->{'Error Flagged'};
+
# and now we parse according to http://wiki.whatwg.org/wiki/Validator.nu_XML_Output
# I wish we could use XML::LibXML::Reader here. but SHAME on those major
# unix distributions still shipping with libxml2 2.6.16… 4 years after its release
@@ -1046,7 +1048,9 @@ sub html5_validate (\$) {
$File->{Templates}->{Error}->param(fatal_missing_checker => "HTML5 Validator");
}
else {
- my $content = $res->decoded_content(charset => 'none');
+ my $content = &get_content($File, $res);
+ return $File if $File->{'Error Flagged'};
+
# and now we parse according to http://wiki.whatwg.org/wiki/Validator.nu_XML_Output
# I wish we could use XML::LibXML::Reader here. but SHAME on those major
# unix distributions still shipping with libxml2 2.6.16… 4 years after its release
@@ -1723,7 +1727,8 @@ sub handle_uri {
scalar($res->request->uri),
);
- my $content = $res->decoded_content(charset => 'none');
+ my $content = &get_content($File, $res);
+ return $File if $File->{'Error Flagged'};
$File->{Bytes} = $content;
$File->{Mode} = $mode;
@@ -1851,6 +1856,31 @@ sub parse_content_type {
}
#
+# Get content with Content-Encodings decoded from a response.
+sub get_content ($$) {
+ my $File = shift;
+ my $res = shift;
+
+ my $content;
+ eval {
+ $content = $res->decoded_content(charset => 'none', raise_error => 1);
+ };
+ if ($@) {
+ (my $errmsg = $@) =~ s/ at .*//s;
+ my $cenc = $res->header("Content-Encoding");
+ my $uri = $res->request->uri;
+ $File->{'Error Flagged'} = TRUE;
+ $File->{Templates}->{Error}->param(fatal_decode_error => TRUE);
+ $File->{Templates}->{Error}->param(fatal_decode_errmsg => $errmsg);
+ $File->{Templates}->{Error}->param(fatal_decode_cenc => $cenc);
+ # Include URI because it might be a subsystem (eg. HTML5 validator) one
+ $File->{Templates}->{Error}->param(fatal_decode_uri => $uri);
+ }
+
+ return $content;
+}
+
+#
# Check recursion level and enforce Max Recursion limit.
sub check_recursion ($$) {
my $File = shift;
diff --git a/share/templates/en_US/fatal-error.tmpl b/share/templates/en_US/fatal-error.tmpl
index c853fc6..d756759 100644
--- a/share/templates/en_US/fatal-error.tmpl
+++ b/share/templates/en_US/fatal-error.tmpl
@@ -55,6 +55,21 @@
</li>
</TMPL_IF>
+<TMPL_IF NAME="fatal_decode_error">
+ <li class="msg_err"><span class="err_type"><img src="images/info_icons/error.png" alt="Error" title="Error" /></span>
+ <p>
+ A fatal error occurred when attempting to decode response body
+ from <TMPL_VAR NAME="fatal_decode_uri" ESCAPE="HTML">.
+ Either we do not support the content encoding specified
+ ("<TMPL_VAR NAME="fatal_decode_cenc" ESCAPE="HTML">"), or an
+ error occurred while decoding it.
+ </p>
+ <p>The error was:
+ <TMPL_VAR NAME="fatal_decode_errmsg" DEFAULT="(no error message given)" ESCAPE="HTML">
+ </p>
+ </li>
+</TMPL_IF>
+
<TMPL_IF NAME="fatal_uri_error">
<li class="msg_err"><span class="err_type"><img src="images/info_icons/error.png" alt="Error" title="Error" /></span>
<p>
diff --git a/share/templates/en_US/soap_fault.tmpl b/share/templates/en_US/soap_fault.tmpl
index 3bea335..04de3a6 100644
--- a/share/templates/en_US/soap_fault.tmpl
+++ b/share/templates/en_US/soap_fault.tmpl
@@ -34,6 +34,23 @@ X-W3C-Validator-Warnings: <TMPL_VAR NAME="valid_warnings_num"></TMPL_IF>
</env:Detail>
</TMPL_IF>
+<TMPL_IF NAME="fatal_decode_error">
+ <env:Reason>
+ <env:Text xml:lang="en-US">Decode Error</env:Text>
+ </env:Reason>
+ <env:Detail>
+ <m:messageid>fatal_decode_error</m:messageid>
+ <m:errordetail xml:lang="en-US">
+ A fatal error occurred when attempting to decode response body
+ from <TMPL_VAR NAME="fatal_decode_uri" ESCAPE="HTML">.
+ Either we do not support the content encoding specified
+ ("<TMPL_VAR NAME="fatal_decode_cenc" ESCAPE="HTML">"), or an
+ error occurred while decoding it.
+ The error was: "<TMPL_VAR NAME="fatal_decode_errmsg" ESCAPE="HTML">".
+ </m:errordetail>
+ </env:Detail>
+</TMPL_IF>
+
<TMPL_IF NAME="fatal_byte_error">
<env:Reason>
<env:Text xml:lang="en-US">Incorrect Bytes detected</env:Text>