Ignore:
Timestamp:
2008-10-15T17:21:15+13:00 (16 years ago)
Author:
mdewsnip
Message:

Moved the xml_safe() function from gtiaction into gsdltools, so it can be used by other classes.

Location:
gsdl/trunk/common-src/src/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/common-src/src/lib/gsdltools.cpp

    r16949 r17545  
    8585  }
    8686}
     87
     88text_t xml_safe(const text_t &text_string)
     89{
     90  text_t text_string_safe;
     91  text_t::const_iterator here = text_string.begin();
     92  text_t::const_iterator end = text_string.end();
     93  while (here != end) {
     94    if (*here == '&') text_string_safe += "&";
     95    else if (*here == '<') text_string_safe += "&lt;";
     96    else if (*here == '>') text_string_safe += "&gt;";
     97    else text_string_safe.push_back(*here);
     98    ++here;
     99  }
     100  return text_string_safe;
     101}
     102
    87103
    88104// gsdl_system creates a new process for the cmd command (which
  • gsdl/trunk/common-src/src/lib/gsdltools.h

    r16895 r17545  
    5252inline text_t dm_js_safe (const text_t &instring) {text_t outstring; dm_js_safe(instring, outstring); return outstring;}
    5353
     54// Convert '&' to "&amp;", '<' to "&lt;", and '>' to "&gt;"
     55text_t xml_safe(const text_t &text_string);
     56
    5457// gsdl_system creates a new process for the cmd command (which
    5558// may contain arguments).
Note: See TracChangeset for help on using the changeset viewer.