--- test/html-webhacc/cc.cgi 2007/11/04 09:15:02 1.22 +++ test/html-webhacc/cc.cgi 2007/11/11 06:57:16 1.24 @@ -1,5 +1,6 @@ #!/usr/bin/perl use strict; +use utf8; use lib qw[/home/httpd/html/www/markup/html/whatpm /home/wakaba/work/manakai2/lib]; @@ -109,7 +110,7 @@ print_source_string_section (\($input->{s}), 'utf-8'); } else { ## TODO: Change HTTP status code?? - print_result_unknown_type_section ($input); + print_result_unknown_type_section ($input, $result); } if (defined $doc or defined $el) { @@ -142,7 +143,8 @@ ]; - for (qw/decode parse parse_xml parse_manifest check check_manifest/) { + for (qw/decode parse parse_html parse_xml parse_manifest + check check_manifest/) { next unless defined $time{$_}; open my $file, '>>', ".cc-$_.txt" or die ".cc-$_.txt: $!"; print $file $char_length, "\t", $time{$_}, "\n"; @@ -217,13 +219,7 @@ require Encode; require Whatpm::HTML; - - $input->{charset} ||= 'ISO-8859-1'; ## TODO: for now. - my $time1 = time; - my $t = Encode::decode ($input->{charset}, $input->{s}); - $time{decode} = time - $time1; - print STDOUT qq[

Parse Errors

@@ -243,23 +239,32 @@ $type =~ tr/ /-/; $type =~ s/\|/%7C/g; $msg .= qq[ [Description]]; - print STDOUT qq[
$msg
\n]; + print STDOUT qq[
], get_error_level_label (\%opt); + print STDOUT qq[$msg
\n]; add_error ('syntax', \%opt => $result); }; my $doc = $dom->create_document; my $el; - $time1 = time; if (defined $inner_html_element and length $inner_html_element) { + $input->{charset} ||= 'ISO-8859-1'; ## TODO: for now. + my $time1 = time; + my $t = Encode::decode ($input->{charset}, $input->{s}); + $time{decode} = time - $time1; + $el = $doc->create_element_ns ('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]); + $time1 = time; Whatpm::HTML->set_inner_html ($el, $t, $onerror); + $time{parse} = time - $time1; } else { - Whatpm::HTML->parse_string ($t => $doc, $onerror); + my $time1 = time; + Whatpm::HTML->parse_byte_string + ($input->{charset}, $input->{s} => $doc, $onerror); + $time{parse_html} = time - $time1; } - $time{parse} = time - $time1; - + print STDOUT qq[
]; return ($doc, $el); @@ -324,7 +329,8 @@ $type =~ tr/ /-/; $type =~ s/\|/%7C/g; $msg .= qq[ [Description]]; - print STDOUT qq[
$msg
\n]; + print STDOUT qq[
], get_error_level_label (\%opt); + print STDOUT qq[$msg
\n]; add_error ('syntax', \%opt => $result); }; @@ -506,7 +512,8 @@ $type =~ s/\|/%7C/g; $msg .= qq[ [Description]]; print STDOUT qq[
] . get_error_label (\%opt) . - qq[
\n
], $msg, "
\n"; + qq[\n
], get_error_level_label (\%opt); + print STDOUT $msg, "
\n"; add_error ('structure', \%opt => $result); }; @@ -691,10 +698,13 @@ print STDOUT qq[ - -]; + + + + +]; my $must_error = 0; my $should_error = 0; @@ -752,15 +762,28 @@ push @nav, ['#result-summary' => 'Result']; } # print_result_section -sub print_result_unknown_type_section ($) { - my $input = shift; +sub print_result_unknown_type_section ($$) { + my ($input, $result) = @_; + my $euri = htescape ($input->{uri}); print STDOUT qq[ -
-

Media type @{[htescape $input->{media_type}]} is not supported!

+
+

Errors

+ +
+
<$euri>
+
Not + supported: + Media type + @{[htescape $input->{media_type}]} + is not supported.
+
]; - push @nav, ['#result-summary' => 'Result']; + push @nav, ['#parse-errors' => 'Errors']; + add_error (char => {level => 'unsupported'} => $result); + add_error (syntax => {level => 'unsupported'} => $result); + add_error (structure => {level => 'unsupported'} => $result); } # print_result_unknown_type_section sub print_result_input_error_section ($) { @@ -787,7 +810,7 @@ if (defined $err->{node}) { $r .= ' ' if length $r; - $r = get_node_path ($err->{node}); + $r = get_node_link ($err->{node}); } if (defined $err->{index}) { @@ -803,6 +826,32 @@ return $r; } # get_error_label +sub get_error_level_label ($) { + my $err = shift; + + my $r = ''; + + if (not defined $err->{level} or $err->{level} eq 'm') { + $r = qq[MUST‐level + error: ]; + } elsif ($err->{level} eq 's') { + $r = qq[SHOULD‐level + error: ]; + } elsif ($err->{level} eq 'w') { + $r = qq[Warning: + ]; + } elsif ($err->{level} eq 'unsupported') { + $r = qq[Not + supported: ]; + } else { + my $elevel = htescape ($err->{level}); + $r = qq[$elevel: + ]; + } + + return $r; +} # get_error_level_label + sub get_node_path ($) { my $node = shift; my @r; @@ -1051,4 +1100,4 @@ =cut -## $Date: 2007/11/04 09:15:02 $ +## $Date: 2007/11/11 06:57:16 $
MUST-level -ErrorsSHOULD-level -ErrorsWarningsScore
MUST‐level +ErrorsSHOULD‐level +ErrorsWarningsScore