From: Stephen L Johnson Date: Wed, 29 Nov 2000 20:36:48 +0000 (+0000) Subject: added wml_escape() to escape WML control chars in display_wml() X-Git-Tag: spong-2_7_2~46 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5dee3f5370513dcc1d3d32baefe96a233e81c614;p=spong.git added wml_escape() to escape WML control chars in display_wml() --- diff --git a/src/lib/Spong/Service.pm b/src/lib/Spong/Service.pm index 3b76ac4..91cf13c 100755 --- a/src/lib/Spong/Service.pm +++ b/src/lib/Spong/Service.pm @@ -332,7 +332,7 @@ sub display_wml { print "
",$self->summary(),"\n"; print "

\n"; foreach $line ( split /\r?\n/s,$self->message() ) { - print "
",$line,"\n"; + print "
",wml_escape($line),"\n"; if ( ++$cnt >= 15 ) { last; } } } @@ -372,12 +372,24 @@ sub add_action_bar { print "
\n"; } +# Escape non-standard HTML characters sub escape { my($toencode) = @_; $toencode=~s/([^ a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg; return $toencode; } +# Escape non-standard WML characters +sub wml_escape { + my($toencode) = @_; + $toencode =~ s/&/&/g; + $toencode =~ s//>/g; + $toencode =~ s/\"/"/g; + $toencode =~ s/\'/'/g; + $toencode =~ s/\?\?/­/g; + return $toencode; +} sub format_duration { my($self,$stime,$rtime) = @_;