Tags:
create new tag
, view all tags

Bug: Verbatim tag should escape HTML entities

Text enclosed in <verbatim> tags should be shown verbatim, e.g. "as is". I noticed that HTML entities like &nbsp; do not get escaped.

Test case

Named entities:
  nbsp:   "&nbsp;"
  iexcl:  "&iexcl;"
  cent:   "&cent;"
Character reference:
  #160:   "&#160;"
  #161:   "&#161;"
  #162:   "&#162;"
HTML tags are OK:
  <b>bold</b>

This should be shown as nbsp:  "&nbsp;" etc.

Environment

TWiki version: TWiki.org on 26 Jul 2004
TWiki plugins: N/A
Server OS: N/A
Web server: N/A
Perl version: N/A
Client OS: N/A
Web Browser: N/A

-- PeterThoeny - 27 Jul 2004

Follow up

This was working correctly in an old 16 Nov 2001 version, but not in TWikiRelease01Feb2003

-- PeterThoeny - 27 Jul 2004

Fix record

Fixed and in SVN.

Modified: twiki/trunk/lib/TWiki.pm
===================================================================
--- twiki/trunk/lib/TWiki.pm    2004-08-03 20:33:33 UTC (rev 1670)
+++ twiki/trunk/lib/TWiki.pm    2004-08-03 20:49:51 UTC (rev 1671)
@@ -3041,8 +3041,9 @@
     for( my $i=0; $i<=$#verbatim; $i++ ) {
         my $val = $verbatim[$i];
         if( $type ne "verbatim" ) {
+            $val =~ s/&/&amp;/g;
             $val =~ s/</&lt;/g;
-            $val =~ s/</&gt;/g;
+            $val =~ s/>/&gt;/g;
             $val =~ s/\t/   /g; # A shame to do this, but been in TWiki.org have converted
                                 # 3 spaces to tabs since day 1
         }

-- PeterThoeny - 03 Aug 2004

Topic revision: r3 - 2004-08-28 - WillNorris
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.