sanitize_string.cpp 564 B

123456789101112131415161718192021
  1. #include <algorithm>
  2. #include "sanitize_string.h"
  3. bool ignoreInLabel(char c)
  4. {
  5. return c == ' ' || c == ':' || c == '.' || c == '/' || c == '&';
  6. }
  7. std::string sanitizeLabel(const std::string &label)
  8. {
  9. std::string out(label);
  10. // conceal labels that contain rtsp URL to prevent sensitive data leaks.
  11. //if (label.find("rtsp:") != std::string::npos)
  12. {
  13. std::hash<std::string> hash_fn;
  14. size_t hash = hash_fn(out);
  15. return std::to_string(hash);
  16. }
  17. out.erase(std::remove_if(out.begin(), out.end(), ignoreInLabel), out.end());
  18. return out;
  19. }