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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Sun Jul 1 10:02:24 2007 UTC (19 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.7: +13 -1 lines
++ ChangeLog	1 Jul 2007 10:02:07 -0000
	* cc.cgi: Return 404 if |PATH_INFO| is different from |/|.
	Link to |error-description|.

	* error-description-source.xml: New.

	* mkdescription.pl: New.

2007-07-01  Wakaba  <wakaba@suika.fam.cx>

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.8 if ($http->meta_variable ('PATH_INFO') ne '/') {
27     print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n400";
28     exit;
29     }
30    
31 wakaba 1.2 my $input_format = $http->parameter ('i') || 'text/html';
32     my $inner_html_element = $http->parameter ('e');
33     my $input_uri = 'thismessage:/';
34 wakaba 1.1
35     my $s = $http->parameter ('s');
36     if (length $s > 1000_000) {
37     print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long";
38     exit;
39     }
40 wakaba 1.2
41 wakaba 1.7 load_text_catalog ('en'); ## TODO: conneg
42    
43 wakaba 1.3 my @nav;
44 wakaba 1.2 print STDOUT qq[Content-Type: text/html; charset=utf-8
45    
46     <!DOCTYPE html>
47     <html lang="en">
48     <head>
49     <title>Web Document Conformance Checker (BETA)</title>
50 wakaba 1.3 <link rel="stylesheet" href="../cc-style.css" type="text/css">
51 wakaba 1.2 </head>
52     <body>
53     <h1>Web Document Conformance Checker (<em>beta</em>)</h1>
54