This source file includes following definitions.
- IsValidObjectPath
#include "dbus/string_util.h"
#include "base/strings/string_util.h"
namespace dbus {
bool IsValidObjectPath(const std::string& value) {
const bool kCaseSensitive = true;
if (!StartsWithASCII(value, "/", kCaseSensitive))
return false;
int element_length = 0;
for (size_t i = 1; i < value.size(); ++i) {
const char c = value[i];
if (c == '/') {
if (element_length == 0)
return false;
element_length = 0;
} else {
const bool is_valid_character =
('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') ||
('0' <= c && c <= '9') || c == '_';
if (!is_valid_character)
return false;
element_length++;
}
}
if (value.size() > 1 && EndsWith(value, "/", kCaseSensitive))
return false;
return true;
}
}