sub escapeHTML { # hack to work around earlier hacks push @_,$_[0] if @_==1 && $_[0] eq 'CGI'; my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_); return undef unless defined($toencode); return $toencode if ref($self) && !$self->{'escape'}; $toencode =~ s{&}{&}gso; $toencode =~ s{<}{<}gso; $toencode =~ s{>}{>}gso; if ($DTD_PUBLIC_IDENTIFIER =~ /[^X]HTML 3\.2/i) { # $quot; was accidentally omitted from the HTML 3.2 DTD -- see # / # . $toencode =~ s{"}{"}gso; } else { $toencode =~ s{"}{"}gso; } my $latin = uc $self->{'.charset'} eq 'ISO-8859-1' || uc $self->{'.charset'} eq 'WINDOWS-1252'; if ($latin) { # bug in some browsers $toencode =~ s{'}{'}gso; $toencode =~ s{\x8b}{‹}gso; $toencode =~ s{\x9b}{›}gso; if (defined $newlinestoo && $newlinestoo) { $toencode =~ s{\012}{ }gso; $toencode =~ s{\015}{ }gso; } } return $toencode; }