/[pub]/test/html-webhacc/cc.cgi
Suika

Contents of /test/html-webhacc/cc.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Sun Jul 1 06:21:46 2007 UTC (19 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.6: +65 -23 lines
++ ChangeLog	1 Jul 2007 06:21:44 -0000
2007-07-01  Wakaba  <wakaba@suika.fam.cx>

	* cc-style.css: New rules for empty error lists,
	error levels, and |code|.

	* cc.cgi: Support for error message catalog.
	Support for empty (zero-length) document.
	(print_source_string): Support for empty document.
	(print_document_tree): Element |has_child_nodes| test
	was incorrect.  Output compat mode and is html flag
	for |Document| node.
	(load_text_catalog, get_text): New functions.

	* LICENSE, large-alert.png, large-info.png, large-stop.png:
	New files.

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3    
4     use lib qw[/home/httpd/html/www/markup/html/whatpm
5     /home/wakaba/work/manakai/lib
6     /home/wakaba/public_html/-temp/wiki/lib];
7     use CGI::Carp qw[fatalsToBrowser];
8 wakaba 1.2 use Scalar::Util qw[refaddr];
9 wakaba 1.1
10     use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module
11    
12 wakaba 1.2 sub htescape ($) {
13     my $s = $_[0];
14     $s =~ s/&/&amp;/g;
15     $s =~ s/</&lt;/g;
16     $s =~ s/>/&gt;/g;
17     $s =~ s/"/&quot;/g;
18     $s =~ s!([\x00-\x09\x0B-\x1F\x7F-\x80])!sprintf '<var>U+%04X</var>', ord $1!ge;
19     return $s;
20     } # htescape
21    
22 wakaba 1.1 my $http = SuikaWiki::Input::HTTP->new;
23    
24     ## TODO: _charset_
25    
26 wakaba 1.2 my $input_format = $http->parameter ('i') || 'text/html';
27     my $inner_html_element = $http->parameter ('e');
28     my $input_uri = 'thismessage:/';
29 wakaba 1.1
30     my $s = $http->parameter ('s');
31     if (length $s > 1000_000) {
32     print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long";
33     exit;
34     }
35 wakaba 1.2
36 wakaba 1.7 load_text_catalog ('en'); ## TODO: conneg
37    
38 wakaba 1.3 my @nav;
39 wakaba 1.2 print STDOUT qq[Content-Type: text/html; charset=utf-8
40    
41     <!DOCTYPE html>
42     <html lang="en">
43     <head>
44     <title>Web Document Conformance Checker (BETA)</title>
45 wakaba 1.3 <link rel="stylesheet" href="../cc-style.css" type="text/css">
46 wakaba 1.2 </head>
47     <body>
48     <h1>Web Document Conformance Checker (<em>beta</em>)</h1>
49    
50 wakaba 1.4 <div id="document-info" class="section">
51 wakaba 1.2 <dl>
52     <dt>Document URI</dt>
53     <dd><code class="URI" lang="">&lt;<a href="@{[htescape $i