| 388 | } |
| 389 | |
| 390 | std::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 | |
| 430 | size_t find_first_substr(const std::string& findin, const std::string findwhat, size_t offset) { |
| 431 | if (findwhat.size()) { |
no test coverage detected