342 {
343 const size_t size = rr.data.size();
344 if (size < 2) {
345 return boost::none;
346 }
347
348 DnsRR_TXT res;
349
350 for (auto it = rr.data.begin(); it != rr.data.end(); ) {
351 unsigned val_size = static_cast<unsigned char>(*it);
352 if (val_size == 0 || it + val_size >= rr.data.end()) {
353 return boost::none;
354 }
355 ++it;
356
357 const auto it_end = it + val_size;
358 const auto it_eq = std::find(it, it_end, '=');
359 if (it_eq > it && it_eq < it_end - 1) {
360 std::string key(it_eq - it, ' ');
361 std::copy(it, it_eq, key.begin());
362
363 if (txt_keys.find(key) != txt_keys.end() || key == "path") {
364
365 std::string value(it_end - it_eq - 1, ' ');
366 std::copy(it_eq + 1, it_end, value.begin());
367 res.data.insert(std::make_pair(std::move(key), std::move(value)));
368 }
369 }
370
371 it = it_end;
372 }
373
374 return std::move(res);
375 }