MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ParseQuery

Method ParseQuery

lib/remote/url.cpp:305–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305bool Url::ParseQuery(const String& query)
306{
307 /* Tokenizer does not like String AT ALL */
308 const std::string& queryStr = query;
309 boost::char_separator<char> sep("&");
310 boost::tokenizer<boost::char_separator<char> > tokens(queryStr, sep);
311
312 for (String token : tokens) {
313 size_t pHelper = token.Find("=");
314
315 if (pHelper == 0)
316 // /?foo=bar&=bar == invalid
317 return false;
318
319 String key = token.SubStr(0, pHelper);
320 String value = Empty;
321
322 if (pHelper != String::NPos && pHelper != token.GetLength() - 1)
323 value = token.SubStr(pHelper+1);
324
325 if (!ValidateToken(value, ACQUERY))
326 return false;
327
328 value = Utility::UnescapeString(value);
329
330 pHelper = key.Find("[]");
331
332 if (pHelper == 0 || (pHelper != String::NPos && pHelper != key.GetLength()-2))
333 return false;
334
335 key = key.SubStr(0, pHelper);
336
337 if (!ValidateToken(key, ACQUERY))
338 return false;
339
340 m_Query.emplace_back(Utility::UnescapeString(key), std::move(value));
341 }
342
343 return true;
344}
345
346bool Url::ParseFragment(const String& fragment)
347{

Callers

nothing calls this directly

Calls 3

FindMethod · 0.80
SubStrMethod · 0.80
GetLengthMethod · 0.45

Tested by

no test coverage detected