in reply to Re: Best way to use escapeHTML
in thread Best way to use escapeHTML

Even this way?
use strict; use CGI qw(:standard escapeHTML); my $q = new CGI; my $test = "What's the big''s deal?!!?? - <script>TEST</script>"; my $comments = $q->escapeHTML( $test ) || ''; print header(); print "test: $comments";

Replies are listed 'Best First'.
Re^3: Best way to use escapeHTML
by ikegami (Patriarch) on Aug 09, 2011 at 03:19 UTC

    Yes, that's what it's for, although your naming really sucks, and you're using || '' against the wrong thing.

    my $comment = $cgi->param('comment') || ''; # or whatever ... my $comment_html = $cgi->escapeHTML($comment); print header(); print "<p>Comments: $comment_html\n";