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