Changeset 2426 for trunk/gsdl/src/recpt/cgiutils.cpp
- Timestamp:
- 2001-05-16T15:38:12+12:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/cgiutils.cpp
r2417 r2426 109 109 // store this key=value pair 110 110 if (!key.empty()) { 111 // if arg occurs multiple times (as is the case with 112 // multiple checkboxes using the same name) we'll 113 // create a comma separated list of all the values 114 // (we should probably use some kind of array here to 115 // avoid problems when values already contain commas) 111 112 // if arg occurs multiple times (as is the case with multiple 113 // checkboxes using the same name) we'll create a comma separated 114 // list of all the values (this uses a hack that encodes naturally 115 // occurring commas as %2C - values will therefore need to be decoded 116 // again before use) - it should use an array instead 116 117 const cgiarginfo *info = argsinfo.getarginfo (key); 117 118 if (info != NULL && info->multiplevalue) { 118 119 text_t newvalue = args[key]; 119 120 if (args.lookupcgiarg(key).source == cgiarg_t::cgi_arg) newvalue += ","; 120 newvalue += value;121 newvalue += encode_commas(value); 121 122 args.setarg (key, newvalue, cgiarg_t::cgi_arg); 122 123 … … 126 127 } 127 128 } 129 } 130 131 text_t encode_commas (const text_t &intext) { 132 133 text_t outtext; 134 135 text_t::const_iterator here = intext.begin (); 136 text_t::const_iterator end = intext.end (); 137 138 while (here != end) { 139 if (*here == ',') outtext += "%2C"; 140 else outtext.push_back (*here); 141 here ++; 142 } 143 return outtext; 144 } 145 146 text_t decode_commas (const text_t &intext) { 147 148 text_t outtext; 149 150 text_t::const_iterator here = intext.begin (); 151 text_t::const_iterator end = intext.end (); 152 153 while (here != end) { 154 if ((here+2<end) && *here == '%' && *(here+1) == '2' && 155 (*(here+2) == 'C' || *(here+2) == 'c')) { 156 here += 2; 157 outtext.push_back(','); 158 159 }else outtext.push_back (*here); 160 here ++; 161 } 162 return outtext; 128 163 } 129 164
Note:
See TracChangeset
for help on using the changeset viewer.