Changeset 2426
- Timestamp:
- 2001-05-16T15:38:12+12:00 (23 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 3 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 -
trunk/gsdl/src/recpt/cgiutils.h
r1285 r2426 39 39 void split_cgi_args (const cgiargsinfoclass &argsinfo, text_t argstr, 40 40 cgiargsclass &args); 41 42 text_t encode_commas (const text_t &intext); 43 text_t decode_commas (const text_t &intext); 41 44 42 45 // turns any '-' in a cgi argument into "(-)" -
trunk/gsdl/src/recpt/collectoraction.cpp
r2418 r2426 41 41 #include "nullproto.h" 42 42 #include "argdb.h" 43 #include "cgiutils.h" 43 44 44 45 #if !defined (__WIN32__) … … 856 857 857 858 text_tarray inputvalues; 858 // this relies on filenames/URLs not being able to contain859 // commas860 859 splitchar (inputarglist.begin(), inputarglist.end(), ',', inputvalues); 861 860 // remove any empty values from the end of the array … … 906 905 rv += "<input type=text name=\"bc1input\" value=\""; 907 906 if (i < numvalues) { 908 rv += dm_safe( inputvalues[i]);907 rv += dm_safe(decode_commas(inputvalues[i])); 909 908 } 910 909 rv += "\" size=50>"; 911 910 if (badsources) { 912 911 if ((i < numvalues) && (!inputvalues[i].empty())) { 913 if (failedsources[ inputvalues[i]] == "1") {912 if (failedsources[decode_commas(inputvalues[i])] == "1") { 914 913 rv += "_iconcross_"; 915 914 } else { … … 1642 1641 1643 1642 text_tarray inputvalues, inputtypes; 1644 // this relies on filenames/URLs not being able to contain commas1645 1643 splitchar (args["bc1input"].begin(), args["bc1input"].end(), ',', inputvalues); 1646 1644 splitchar (args["bc1inputtype"].begin(), args["bc1inputtype"].end(), ',', inputtypes); … … 1651 1649 text_t type = "file://"; // default 1652 1650 if (i < numtypes) type = inputtypes[i]; 1653 options += " -download \"" + type + format_url( inputvalues[i]) + "\"";1651 options += " -download \"" + type + format_url(decode_commas(inputvalues[i])) + "\""; 1654 1652 } 1655 1653 } … … 1852 1850 1853 1851 text_tarray inputvalues; 1854 // this relies on filenames/URLs not being able to contain1855 // commas1856 char *tmp = args["bc1input"].getcstr();1857 1852 splitchar (args["bc1input"].begin(), args["bc1input"].end(), ',', inputvalues); 1858 1853 … … 1864 1859 1865 1860 for (int i = 0; i < numvalues; i++) { 1866 text_t value = format_url( inputvalues[i]);1861 text_t value = format_url(decode_commas(inputvalues[i])); 1867 1862 text_t type = "file://"; // default 1868 1863 if (!value.empty()) { … … 1875 1870 if (type == "file://") { 1876 1871 if (!file_exists(value) && !directory_exists(value)) { 1877 failedsources[ inputvalues[i]] = "1";1872 failedsources[decode_commas(inputvalues[i])] = "1"; 1878 1873 badsources = true; 1879 1874 } 1880 1875 } else if (type == "http://") { 1881 1876 if (gsdl_system ("perl -S ping.pl -quiet http://" + value, true, logout)) { 1882 failedsources[ inputvalues[i]] = "1";1877 failedsources[decode_commas(inputvalues[i])] = "1"; 1883 1878 badsources = true; 1884 1879 } 1885 1880 } else if (type == "ftp://") { 1886 1881 if (gsdl_system ("perl -S ping.pl -quiet ftp://" + value, true, logout)) { 1887 failedsources[ inputvalues[i]] = "1";1882 failedsources[decode_commas(inputvalues[i])] = "1"; 1888 1883 badsources = true; 1889 1884 }
Note:
See TracChangeset
for help on using the changeset viewer.