[Dart] Ctrl characters in test output

Brad King brad.king at kitware.com
Mon, 21 Jan 2002 13:16:27 -0500 (EST)


> Clearly, such characters need to be escaped somehow. I don't know
> enough xml/xsl to know whether the escape should be done client-side
> or server side.
For some reason we never encountered this problem before, and now this is
the 4th case I've seen in the last two weeks.  The fix is to put proper
escaping of more characters in the XMLSafeString procedure in
Dart/Source/Client/Utility.tcl.  However, there are problems doing this
for Tcl versions before 8.1 (at least for null characters).

There is also the argument that since the characters will be placed in
HTML web pages, those that are invalid for HTML should be either removed
completely, replaced with a "big-red-flag", or replace dwith proper HTML
escape sequences.

In order to make this change correctly, we need to detect the Tcl version.  
If it is before 8.1, then a loop like the one below (from Sebastian) is
needed for some of the character replacements.  Other than that, the rest
of the regex list needs to be extended for the other invalid characters.

-Brad

Sebastien Barre wrote:

This seem to work on my Cygwin Tcl 8.0

proc clean_null_char {str} {
     set res ""
     set len [string length $str]
     for {set i 0} {$i < $len} {incr i} {
         set char [string index $str $i]
         if {$char != "\0"} {
             append res $char
         }
     }
     return $res
}

puts [clean_null_char "ab\0cd"]