MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / url_decode

Function url_decode

plugins/plugin_utils/plugin_utils.cpp:390–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390std::string url_decode(const std::string& text) {
391 std::string destination;
392
393 std::string::const_iterator itr = text.begin();
394 while (itr != text.end()) {
395 if (*itr != '%' && *itr != '+') {
396 destination += *itr++;
397 }
398 else if (*itr == '+') {
399 destination += " ";
400 itr++;
401 }
402 else {
403 char hex[5] = "0x00";
404
405 itr++;
406 if (itr == text.end()) {
407 return destination;
408 }
409
410 hex[2] = *itr;
411
412 itr++;
413 if (itr == text.end()) {
414 return destination;
415 }
416
417 hex[3] = *itr;
418
419 unsigned int val = 0;
420 sscanf(hex, "%x", &val);
421 if (val != 0) {
422 destination += (char)val;
423 }
424 itr++;
425 }
426 }
427 return destination;
428}
429
430size_t find_first_substr(const std::string& findin, const std::string findwhat, size_t offset) {
431 if (findwhat.size()) {

Callers 2

fillRequestMethod · 0.85
processMethod · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected