#!/usr/bin/perl BEGIN { use CGI::Carp qw(fatalsToBrowser set_message); set_message("Congratulations! You found a bug in my program."); } # Security measures. See man 1 perlsec $ENV{PATH} = "/bin:/usr/bin"; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; use strict; use CGI; my ($name) = CGI::param("name"); my ($mark) = "###man.cgi###"; my ($i, @s, @deco, @text, $a, $b, $c); print <
eof

open F, "man $name |" or die;
while () {
    while (s/((.\x8.)+)/$mark/) {
	@s = split //, $1;
	$#deco = $#text = $#s/3;
	for ($i=0; $i<=$#deco; ++$i) {
	    $deco[$i] = $s[$i*3];
	    $text[$i] = $s[$i*3+2];
	}
	$a = join "", @deco;
	$b = join "", @text;
	$c = ($a eq $b) ? "b" : "u";
	s!$mark!<$c>$b!;
    }
    print;
}
close F;

print <


eof