]> git.etc.gen.nz Git - spong.git/commitdiff
added wml_escape() to escape WML control chars in display_wml()
authorStephen L Johnson <sjohnson@monsters.org>
Wed, 29 Nov 2000 20:36:48 +0000 (20:36 +0000)
committerStephen L Johnson <sjohnson@monsters.org>
Wed, 29 Nov 2000 20:36:48 +0000 (20:36 +0000)
src/lib/Spong/Service.pm

index 3b76ac430ec7d30ae800f57022201fa9e94e8373..91cf13ce1a303964a2bc744512f8c879493c0fbe 100755 (executable)
@@ -332,7 +332,7 @@ sub display_wml {
       print "<br/>",$self->summary(),"\n";
       print "<br/><br/>\n";
       foreach $line ( split /\r?\n/s,$self->message() ) {
-         print "<br/>",$line,"\n";
+         print "<br/>",wml_escape($line),"\n";
          if ( ++$cnt >= 15 ) { last; }
       }
    }
@@ -372,12 +372,24 @@ sub add_action_bar {
    print "<hr>\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/&/&amp;/g;
+    $toencode =~ s/</&lt;/g;
+    $toencode =~ s/>/&gt;/g;
+    $toencode =~ s/\"/&quot;/g;
+    $toencode =~ s/\'/&apos;/g;
+    $toencode =~ s/\?\?/&shy;/g;
+    return $toencode;
+}
 sub format_duration {
     my($self,$stime,$rtime) = @_;