in reply to clean html tags
For just escaping HTML entities, I use this code:
It's best to escape the data as it's coming in; otherwise it's very difficult to distinguish between, for example, a less-than sign that should be converted to < and one that is part of the markup.{ # closure my %HTML_ESCAPE = ( "\xa0" => " ", "&" => "&", "'" => "'", "\"" => """, "<" => "<", ">" => ">", ); sub html_escape { return '' unless defined($_[0]); (my $t=$_[0]) =~ s/([\xa0\'\"&<>])/$HTML_ESCAPE{$1}/g; $t; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: clean html tags
by dorward (Curate) on Jan 26, 2007 at 10:14 UTC | |
by sgifford (Prior) on Jan 26, 2007 at 19:30 UTC | |
by dorward (Curate) on Jan 27, 2007 at 01:01 UTC | |
by sgifford (Prior) on Mar 20, 2007 at 21:17 UTC |
In Section
Seekers of Perl Wisdom