diff options
author | Adrian Thurston <thurston@complang.org> | 2009-02-25 03:22:08 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2009-02-25 03:22:08 +0000 |
commit | e544db3aa8d2cd36ebbeb5ad2e71c17b6ec7de29 (patch) | |
tree | 13a113c569428274a51fda48ffdffd6e7d3ae397 | |
parent | 0ab005c28a931a20aec401cd6730bed72cc64c42 (diff) | |
download | colm-e544db3aa8d2cd36ebbeb5ad2e71c17b6ec7de29.tar.gz |
Need to escape '<', '>', and '&'.
-rw-r--r-- | colm/tree.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/colm/tree.cpp b/colm/tree.cpp index dce1e5e8..fafef8b0 100644 --- a/colm/tree.cpp +++ b/colm/tree.cpp @@ -479,7 +479,13 @@ void print_tree( ostream &out, Tree **&sp, Program *prg, Tree *tree ) void xml_escape_data( const char *data, long len ) { for ( int i = 0; i < len; i++ ) { - if ( 32 <= data[i] && data[i] <= 126 ) + if ( data[i] == '<' ) + cout << "<"; + else if ( data[i] == '>' ) + cout << ">"; + else if ( data[i] == '&' ) + cout << "&"; + else if ( 32 <= data[i] && data[i] <= 126 ) cout << data[i]; else cout << "&#" << ((unsigned)data[i]) << ';'; |