--- test/html-webhacc/cc.cgi 2007/11/19 12:20:14 1.27
+++ test/html-webhacc/cc.cgi 2008/02/10 02:05:30 1.31
@@ -89,47 +89,7 @@
];
my $result = {conforming_min => 1, conforming_max => 1};
- print_http_header_section ($input, $result);
-
- my $doc;
- my $el;
- my $manifest;
-
- if ($input->{media_type} eq 'text/html') {
- ($doc, $el) = print_syntax_error_html_section ($input, $result);
- print_source_string_section
- (\($input->{s}), $input->{charset} || $doc->input_encoding);
- } elsif ({
- 'text/xml' => 1,
- 'application/atom+xml' => 1,
- 'application/rss+xml' => 1,
- 'application/svg+xml' => 1,
- 'application/xhtml+xml' => 1,
- 'application/xml' => 1,
- }->{$input->{media_type}}) {
- ($doc, $el) = print_syntax_error_xml_section ($input, $result);
- print_source_string_section (\($input->{s}), $doc->input_encoding);
- } elsif ($input->{media_type} eq 'text/cache-manifest') {
-## TODO: MUST be text/cache-manifest
- $manifest = print_syntax_error_manifest_section ($input, $result);
- print_source_string_section (\($input->{s}), 'utf-8');
- } else {
- ## TODO: Change HTTP status code??
- print_result_unknown_type_section ($input, $result);
- }
-
- if (defined $doc or defined $el) {
- print_structure_dump_dom_section ($doc, $el);
- my $elements = print_structure_error_dom_section ($doc, $el, $result);
- print_table_section ($elements->{table}) if @{$elements->{table}};
- print_id_section ($elements->{id}) if keys %{$elements->{id}};
- print_term_section ($elements->{term}) if keys %{$elements->{term}};
- print_class_section ($elements->{class}) if keys %{$elements->{class}};
- } elsif (defined $manifest) {
- print_structure_dump_manifest_section ($manifest);
- print_structure_error_manifest_section ($manifest, $result);
- }
-
+ check_and_print ($input => $result);
print_result_section ($result);
} else {
print STDOUT qq[];
@@ -166,7 +126,7 @@
$result->{conforming_min} = 0;
} elsif ($err->{level} eq 'w' or $err->{level} eq 'g') {
$result->{$layer}->{warning}++;
- } elsif ($err->{level} eq 'unsupported') {
+ } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') {
$result->{$layer}->{unsupported}++;
$result->{unsupported} = 1;
} else {
@@ -185,6 +145,51 @@
}
} # add_error
+sub check_and_print ($$) {
+ my ($input, $result) = @_;
+
+ print_http_header_section ($input, $result);
+
+ my $doc;
+ my $el;
+ my $manifest;
+
+ if ($input->{media_type} eq 'text/html') {
+ ($doc, $el) = print_syntax_error_html_section ($input, $result);
+ print_source_string_section
+ (\($input->{s}), $input->{charset} || $doc->input_encoding);
+ } elsif ({
+ 'text/xml' => 1,
+ 'application/atom+xml' => 1,
+ 'application/rss+xml' => 1,
+ 'application/svg+xml' => 1,
+ 'application/xhtml+xml' => 1,
+ 'application/xml' => 1,
+ }->{$input->{media_type}}) {
+ ($doc, $el) = print_syntax_error_xml_section ($input, $result);
+ print_source_string_section (\($input->{s}), $doc->input_encoding);
+ } elsif ($input->{media_type} eq 'text/cache-manifest') {
+## TODO: MUST be text/cache-manifest
+ $manifest = print_syntax_error_manifest_section ($input, $result);
+ print_source_string_section (\($input->{s}), 'utf-8');
+ } else {
+ ## TODO: Change HTTP status code??
+ print_result_unknown_type_section ($input, $result);
+ }
+
+ if (defined $doc or defined $el) {
+ print_structure_dump_dom_section ($doc, $el);
+ my $elements = print_structure_error_dom_section ($doc, $el, $result);
+ print_table_section ($elements->{table}) if @{$elements->{table}};
+ print_id_section ($elements->{id}) if keys %{$elements->{id}};
+ print_term_section ($elements->{term}) if keys %{$elements->{term}};
+ print_class_section ($elements->{class}) if keys %{$elements->{class}};
+ } elsif (defined $manifest) {
+ print_structure_dump_manifest_section ($manifest);
+ print_structure_error_manifest_section ($manifest, $result);
+ }
+} # check_and_print
+
sub print_http_header_section ($$) {
my ($input, $result) = @_;
return unless defined $input->{header_status_code} or
@@ -806,9 +811,9 @@
];
push @nav, ['#parse-errors' => 'Errors'];
- add_error (char => {level => 'unsupported'} => $result);
- add_error (syntax => {level => 'unsupported'} => $result);
- add_error (structure => {level => 'unsupported'} => $result);
+ add_error (char => {level => 'u'} => $result);
+ add_error (syntax => {level => 'u'} => $result);
+ add_error (structure => {level => 'u'} => $result);
} # print_result_unknown_type_section
sub print_result_input_error_section ($) {
@@ -865,7 +870,7 @@
} elsif ($err->{level} eq 'w') {
$r = qq[Warning:
];
- } elsif ($err->{level} eq 'unsupported') {
+ } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') {
$r = qq[Not
supported: ];
} else {
@@ -928,6 +933,7 @@
sub get_text ($) {
my ($type, $level, $node) = @_;
$type = $level . ':' . $type if defined $level;
+ $level = 'm' unless defined $level;
my @arg;
{
if (defined $Msg->{$type}) {
@@ -952,13 +958,13 @@
? htescape ($node->owner_element->manakai_local_name)
: ''
}ge;
- return ($type, $Msg->{$type}->[0], $msg);
+ return ($type, 'level-' . $level . ' ' . $Msg->{$type}->[0], $msg);
} elsif ($type =~ s/:([^:]*)$//) {
unshift @arg, $1;
redo;
}
}
- return ($type, '', htescape ($_[0]));
+ return ($type, 'level-'.$level, htescape ($_[0]));
} # get_text
}
@@ -1014,6 +1020,7 @@
$ua->protocols_allowed ([qw/http/]);
$ua->max_size (1000_000);
my $req = HTTP::Request->new (GET => $request_uri);
+ $req->header ('Accept-Encoding' => 'identity, *; q=0');
my $res = $ua->request ($req);
## TODO: 401 sets |is_success| true.
if ($res->is_success or $http->get_parameter ('error-page')) {
@@ -1149,4 +1156,4 @@
=cut
-## $Date: 2007/11/19 12:20:14 $
+## $Date: 2008/02/10 02:05:30 $