Changeset 607


Ignore:
Timestamp:
1999-09-21T23:30:39+12:00 (25 years ago)
Author:
sjboddie
Message:

added ability to escape out '-' in saved args (currently
with a 'Z' ???)

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/cgiutils.cpp

    r533 r607  
    2828/*
    2929   $Log$
     30   Revision 1.9  1999/09/21 11:30:39  sjboddie
     31   added ability to escape out '-' in saved args (currently
     32   with a 'Z' ???)
     33
    3034   Revision 1.8  1999/09/07 04:56:53  sjboddie
    3135   added GPL notice
     
    144148   
    145149    // convert %xx and + to their appropriate equivalents
    146     decode_cgi_arg (value);
     150    if (key != "e") decode_cgi_arg (value);
     151
    147152    value.setencoding(1); // other encoding
    148153    // store this key=value pair
    149154    if (!key.empty()) args.setarg (key, value, cgiarg_t::cgi_arg);
    150155  }
     156}
     157
     158text_t minus_safe (const text_t &intext) {
     159
     160  text_t outtext;
     161
     162  text_t::const_iterator here = intext.begin ();
     163  text_t::const_iterator end = intext.end ();
     164
     165  while (here != end) {
     166    if (*here == '-') outtext += "Z-";
     167    else outtext.push_back (*here);
     168    here ++;
     169  }
     170  return outtext;
    151171}
    152172
     
    164184    ((c >= 'A') && (c <= 'Z')) ||
    165185    ((c >= '0') && (c <= '9')) ||
    166     (c == '-') || (c == '+')) {
     186    (c == '+') || (c == '%')) {
    167187      // alphanumeric character
    168188      outtext.push_back(c);
     
    189209                       text_t::const_iterator last,
    190210                       text_t &argname) {
     211  text_t::const_iterator sav = first;
    191212  first = getdelimitstr (first, last, '-', argname);
    192213  return first;
     
    330351    // found the argument information
    331352    if (argnameinfo->multiplechar) {
     353      text_t::const_iterator sav = arg_ehere;
    332354      arg_ehere = getdelimitstr (arg_ehere, arg_eend, '-', argvalue);
     355      // replace any '-' chars escaped with 'Z'
     356      if (*(arg_ehere-2) == 'Z') {
     357        argvalue.clear();
     358        arg_ehere = (findchar (arg_ehere, arg_eend, '-')) + 1;
     359        while (sav != (arg_ehere-1)) {
     360          if (!((*sav == 'Z') && (*(sav+1) == '-'))) argvalue.push_back (*sav);
     361          sav ++;
     362        }
     363      }
     364
    333365      argvalue.setencoding(1); // other encoding
    334366      if (!argvalue.empty()) args.setdefaultarg (argname, argvalue, cgiarg_t::compressed_arg);
     
    404436    // found the argument information
    405437    if (argnameinfo->multiplechar) {
    406       // multiple character argument -- make sure it is cgi safe
    407       compressed_args += cgi_safe (outconvert.convert(args[argname]));
     438      // multiple character argument -- sort out any '-' chars
     439      compressed_args += minus_safe (outconvert.convert(args[argname]));
    408440      if (saveconfhere != saveconfend) compressed_args.push_back ('-');
    409441
  • trunk/gsdl/src/recpt/cgiutils.h

    r533 r607  
    4040// split up the cgi arguments
    4141void split_cgi_args (text_t argstr, cgiargsclass &args);
     42
     43// turns any '-' in a cgi argument into "(-)"
     44text_t minus_safe (const text_t &intext);
    4245
    4346// returns the encoded version of a cgi argument
Note: See TracChangeset for help on using the changeset viewer.