#!/usr/bin/perl -w # simple echo server use strict; use Encode qw/ decode /; use CGI; binmode STDOUT, ":utf8"; # handle Unicode output sub noHTML { my ($string) = @_; $string =~ s/&/\&/g; # remove tags and Unicode entities $string =~ s//\>/g; return $string; } # noHTML my $input = decode('UTF-8', CGI::param('parameter1') // 'no input'); $input = noHTML($input); # untaint to prevent XSS # HTML header print "Content-Type: text/html; charset=utf-8\n"; print "\n"; # separator before content # HTTP content print " Echo result

You typed in $input.

";