-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtalkfilters.pl
executable file
·52 lines (32 loc) · 1.14 KB
/
talkfilters.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/local/bin/perl
#---------------------------------------------------------------------------
# Yank in and parse the stuff the browser sent us.
#---------------------------------------------------------------------------
$in = $ENV{'CONTENT_LENGTH'};
if($in == 0)
{
# No form input; so read query string instead
$in = $ENV{'QUERY_STRING'};
}
else
{
# Form input, so parse it.
read(STDIN, $in, $ENV{'CONTENT_LENGTH'}); # grab the chunk of input
}
$in =~ s/\+/ /g; # convert +'s to spaces
$in =~ s/%(..)/pack("c", hex($1))/ge; # expand escape codes
@vars = split('&', $in);
$text = substr($vars[0], index($vars[0], '=') + 1);
$filter = substr($vars[1], index($vars[1], '=') + 1);
print "Content-type: text/html\n\n";
print "<html><head><title>The GNU Talkfilters - Output</title></head>";
print "<body bgcolor=\"white\" fgcolor=\"black\">\n";
print "<hr>\n";
print "<pre>\n";
select((select(STDOUT), $| = 1)[0]);
open (FOUT, "| /usr/local/bin/$filter | /usr/local/bin/wrap");
print FOUT $text;
close FOUT;
print "</pre>\n";
print "<hr>\n";
print "</body></html>\n";