|
33 | 33 | #include <memory> |
34 | 34 | #include <vector> |
35 | 35 | #include <string.h> |
| 36 | +#include <ctype.h> |
36 | 37 |
|
37 | 38 | const char *item_prop_kind = "_kind"; |
38 | 39 | const char *item_prop_more = "_more"; |
@@ -1209,9 +1210,41 @@ Bool_t TRootSniffer::ExecuteCmd(const std::string &path, const std::string &opti |
1209 | 1210 | return kTRUE; |
1210 | 1211 | } |
1211 | 1212 |
|
1212 | | - TString svalue = DecodeUrlOptionValue(argvalue, kTRUE); |
1213 | 1213 | argname = TString("%") + argname + TString("%"); |
1214 | | - method.ReplaceAll(argname, svalue); |
| 1214 | + auto p = method.Index(argname); |
| 1215 | + if (p == kNPOS) |
| 1216 | + continue; |
| 1217 | + |
| 1218 | + method.Remove(p, argname.Length()); |
| 1219 | + |
| 1220 | + if ((p > 0) && (p < method.Length()) && (method.Length() > 1) && (method[p-1] == '"') && (method[p] == '"')) { |
| 1221 | + // command definition has quotes around argument |
| 1222 | + // one can insert value from URL removing quotes |
| 1223 | + method.Insert(p, DecodeUrlOptionValue(argvalue, kTRUE)); |
| 1224 | + continue; |
| 1225 | + } |
| 1226 | + |
| 1227 | + // extract argument without removing quotes |
| 1228 | + TString svalue = DecodeUrlOptionValue(argvalue, kFALSE); |
| 1229 | + |
| 1230 | + if ((svalue.Length() > 1) && (svalue[0] == '"') && (svalue[svalue.Length() - 1] == '"')) { |
| 1231 | + // if value itself has quotes, all special symbols already escaped and one can insert it as is |
| 1232 | + method.Insert(p, svalue); |
| 1233 | + continue; |
| 1234 | + } |
| 1235 | + |
| 1236 | + Bool_t is_numeric = kTRUE; |
| 1237 | + // expect decimal, hex or float values here, E/e also belong to hex |
| 1238 | + for(Size_t i = 0; is_numeric && (i < svalue.Length()); ++i) |
| 1239 | + is_numeric = std::isxdigit(svalue[i]) || std::strchr(".+-", svalue[i]); |
| 1240 | + |
| 1241 | + // always quote content which not numeric |
| 1242 | + if (!is_numeric) |
| 1243 | + svalue = "\"" + svalue + "\""; |
| 1244 | + else if (svalue.IsNull()) |
| 1245 | + svalue = "0"; |
| 1246 | + |
| 1247 | + method.Insert(p, svalue); |
1215 | 1248 | } |
1216 | 1249 | } |
1217 | 1250 |
|
|
0 commit comments