Changeset 17545


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
Files:
4 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).
  • gsdl/trunk/runtime-src/src/recpt/gtiaction.cpp

    r13941 r17545  
    655655
    656656
    657 text_t gtiaction::xml_safe(const text_t &text_string)
    658 {
    659   text_t text_string_safe;
    660   text_t::const_iterator here = text_string.begin();
    661   text_t::const_iterator end = text_string.end();
    662   while (here != end) {
    663     if (*here == '&') text_string_safe += "&amp;";
    664     else if (*here == '<') text_string_safe += "&lt;";
    665     else if (*here == '>') text_string_safe += "&gt;";
    666     else text_string_safe.push_back(*here);
    667     ++here;
    668   }
    669 
    670   return text_string_safe;
    671 }
    672 
    673 
    674 
    675657char* xml_get_attribute(const char** attributes, char* attribute_name)
    676658{
  • gsdl/trunk/runtime-src/src/recpt/gtiaction.h

    r13692 r17545  
    107107  text_t escape_all(text_t source_string, char character_to_escape);
    108108
    109   text_t xml_safe(const text_t &text_string);
    110 
    111109  void process_gti_submissions(displayclass& disp, cgiargsclass& args, ostream& logout, bool force_submission);
    112110
Note: See TracChangeset for help on using the changeset viewer.