ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/web/cgi-bin/docs.cgi
(Generate patch)

Comparing web/cgi-bin/docs.cgi (file contents):
Revision 1.1 by tdb, Wed Oct 25 23:56:27 2000 UTC vs.
Revision 1.3 by tdb, Thu Nov 9 22:03:56 2000 UTC

# Line 19 | Line 19 | my ($bottom) = "../bottom.inc";
19  
20  
21   my ($query) = new CGI;
22 < my ($doci) = ($query->param('doc') =~ /^\s*(.*?\.txt)\s*$/);
23 < my ($doc) = "../documentation/$doci";
22 > my ($doc) = ($query->param('doc') =~ /^\s*(.*?\.txt)\s*$/);
23 > $doc = "../documentation/".$doc;
24  
25 < print "content-type: text/html\n\n";
25 > print "Content-type: text/html\n\n";
26  
27   print <<"END";
28   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
# Line 31 | Line 31 | print <<"END";
31      docs.cgi
32      Web-based text file viewer and formatter.
33      Created by pjm2 19/10/2000
34 <    Last modified 19/10/2000
34 >    Last modified 02/11/2000
35   -->
36  
37   <html>
# Line 50 | Line 50 | print <<"END";
50    <td valign="top">
51   END
52  
53 < &print_file($left);
53 > &print_html($left);
54  
55   print <<"END";
56  
# Line 58 | Line 58 | print <<"END";
58    <td valign="top">
59   END
60  
61 < &print_file($title);
62 <
63 < print "<PRE>\n";
61 > &print_html($title);
62   &print_file($doc);
63 < print "</PRE>\n";
63 > &print_html($bottom);
64  
67 &print_file($bottom);
68
65   print <<"END";
66  
67    </td>
# Line 79 | Line 75 | END
75  
76   exit 0;
77  
78 + # Print a file, whilst escaping HTML: -
79   sub print_file ($) {
80 +    my ($urls) = '(' . join ('|', qw{
81 +                       http
82 +                       telnet
83 +                       gopher
84 +                       file
85 +                       wais
86 +                       ftp
87 +                       } )
88 +                   . ')';
89 +    
90 +    my ($ltrs) = '\w';
91 +    my ($gunk) = '/#~:.?+=&%@!\-';
92 +    my ($punc) = '.:?\-';
93 +    my ($any) = "${ltrs}${gunk}${punc}";
94      my ($filename) = @_;
84    print `cat $filename`;
85 }
86
87 sub print_file_old ($) {
88    my ($filename) = @_;
95      open(FILE, $filename) or die "Cannot open $filename: $!\n";
96 <    while (my ($line) = <FILE>) {
97 <        print $line;
96 >    print "<pre>\n";
97 >    # Use $_ implicitly throughout.
98 >    while (<FILE>) {
99 >        # Must do the next line first!
100 >        s/&/&amp;/g;
101 >        s/</&lt;/g;
102 >        s/>/&gt;/g;
103 >        s/"/&quot;/g;
104 >        s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox;
105 >        print;
106      }
107 +    print "</pre>";
108   }
109  
110 + # Print a file without escaping HTML: -
111 + sub print_html ($) {
112 +    my ($filename) = @_;
113 +    print `cat $filename`;
114 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines