--- test/html-webhacc/cc.cgi 2008/07/20 14:58:24 1.53 +++ test/html-webhacc/cc.cgi 2008/07/21 09:15:55 1.57 @@ -44,121 +44,39 @@ ]); my $input = get_input_document ($http, $dom); + $out->input ($input); $out->unset_flush; - my $char_length = 0; - - $out->start_section (id => 'document-info', title => 'Information'); - $out->html (qq[
]);
- $out->text ($input->{media_type});
- $out->html (qq[
]);
- if ($input->{media_type_overridden}) {
- $out->html ('(overridden)');
- } elsif (defined $input->{official_type}) {
- if ($input->{media_type} eq $input->{official_type}) {
- #
- } else {
- $out->html ('(sniffed; official type is: ');
- $out->text ($input->{official_type});
- $out->html ('
)');
- }
- } else {
- $out->html ('(sniffed)');
- }
- $out->html (q[');
- $out->text ($input->{charset});
- $out->html ('
');
- } else {
- $out->text ('(none)');
- }
- $out->html (' overridden') if $input->{charset_overridden};
- $out->html (qq[
-@{[htescape $subinput->{media_type}]}
- <$ebaseuri>
Note: Due to the limitation of the -network library in use, the content of this section might -not be the real header.
- -Status code | ]; - print STDOUT qq[]; - $out->code ($input->{header_status_code}); - } - if (defined $input->{header_status_text}) { - print STDOUT qq[ |
---|---|
Status text | ]; - print STDOUT qq[]; - $out->code ($input->{header_status_text}); - } - - for (@{$input->{header_field}}) { - print STDOUT qq[ |
]; - $out->code ($_->[0]); - print STDOUT qq[ | ]; - $out->code ($_->[1]); - } - - print STDOUT qq[ |
@{[htescape $id]}
<' . $euri .
- '>
';
- } elsif (defined $resource->{bnodeid}) {
- return htescape ('_:' . $resource->{bnodeid});
- } elsif ($resource->{nodes}) {
- return '(rdf:XMLLiteral)';
- } elsif (defined $resource->{value}) {
- my $elang = htescape (defined $resource->{language}
- ? $resource->{language} : '');
- my $r = qq[] . htescape ($resource->{value}) . '
';
- if (defined $resource->{datatype}) {
- my $euri = htescape ($resource->{datatype});
- $r .= '^^<' . $euri .
- '>
';
- } elsif (length $resource->{language}) {
- $r .= '@' . htescape ($resource->{language});
- }
- return $r;
- } else {
- return '??';
- }
-} # get_rdf_resource_html
-
-sub print_result_section ($) {
- my $result = shift;
-
- $out->start_section (id => 'result-summary',
- title => 'Result');
-
- if ($result->{unsupported} and $result->{conforming_max}) {
- print STDOUT qq[The conformance - checker cannot decide whether the document is conforming or - not, since the document contains one or more unsupported - features. The document might or might not be conforming.
]; - } elsif ($result->{conforming_min}) { - print STDOUT qq[No conformance-error is - found in this document.
]; - } elsif ($result->{conforming_max}) { - print STDOUT qq[This document - is likely non-conforming, but in rare case - it might be conforming.
]; - } else { - print STDOUT qq[This document is - non-conforming.
]; - } - - print STDOUT qq[- | MUST‐level -Errors | -SHOULD‐level -Errors | -Warnings | -Score | ||
---|---|---|---|---|---|---|
$label | $result->{$_->[1]}->{must}$uncertain | $result->{$_->[1]}->{should}$uncertain | $result->{$_->[1]}->{warning}$uncertain | ]; - if ($uncertain) { - print qq[−∞..$result->{$_->[1]}->{score_max}]; - } elsif ($result->{$_->[1]}->{score_min} != $result->{$_->[1]}->{score_max}) { - print qq[ | $result->{$_->[1]}->{score_min}..$result->{$_->[1]}->{score_max}]; - } else { - print qq[ | $result->{$_->[1]}->{score_min}]; - } - print qq[ / 20]; - } - - $score_max += $score_base; - - print STDOUT qq[ - |
Semantics | 0? | 0? | 0? | −∞..$score_base / 20 - | ||
Total | -$must_error? | -$should_error? | -$warning? | -−∞..$score_max / 100 - |
Important: This conformance checking service -is under development. The result above might be wrong.
]; - $out->end_section; -} # print_result_section - -sub print_result_input_error_section ($) { - my $input = shift; - $out->start_section (id => 'result-summary', title => 'Result'); - print STDOUT qq[ -Input Error: @{[htescape ($input->{error_status_text})]}
]; - $out->end_section; -} # print_result_input_error_section { my $Msg = {}; @@ -581,15 +196,18 @@ sub get_input_document ($$) { my ($http, $dom) = @_; - my $request_uri = $http->get_parameter ('uri'); + require Encode; + my $request_uri = Encode::decode ('utf-8', $http->get_parameter ('uri')); my $r = WebHACC::Input->new; if (defined $request_uri and length $request_uri) { my $uri = $dom->create_uri_reference ($request_uri); unless ({ http => 1, }->{lc $uri->uri_scheme}) { - return {uri => $request_uri, request_uri => $request_uri, - error_status_text => 'URI scheme not allowed'}; + $r = WebHACC::Input::Error->new; + $r->{uri} = $request_uri; + $r->{request_uri} = $request_uri; + $r->{error_status_text} = 'URL scheme not allowed'; } require Message::Util::HostPermit; @@ -616,8 +234,11 @@ Allow host=* EOH unless ($host_permit->check ($uri->uri_host, $uri->uri_port || 80)) { - return {uri => $request_uri, request_uri => $request_uri, - error_status_text => 'Connection to the host is forbidden'}; + my $r = WebHACC::Input::Error->new; + $r->{uri} = $request_uri; + $r->{request_uri} = $request_uri; + $r->{error_status_text} = 'Connection to the host is forbidden'; + return $r; } require LWP::UserAgent; @@ -767,4 +388,4 @@ =cut -## $Date: 2008/07/20 14:58:24 $ +## $Date: 2008/07/21 09:15:55 $