* @brief Validate a property key string. * * Keys must not be empty, must not exceed 256 characters, must not contain * control characters (< 0x20), and must not start with the "restapi." prefix. * * @param key The property key to validate. * @return true if valid, false otherwise. */
| 231 | * @return true if valid, false otherwise. |
| 232 | */ |
| 233 | bool ValidatePropertyKey(const std::string& key) |
| 234 | { |
| 235 | if (key.empty() || key.size() > 256) |
| 236 | return false; |
| 237 | if (key.rfind("restapi.", 0) == 0) |
| 238 | return false; |
| 239 | return std::none_of(key.begin(), key.end(), [](char c) { |
| 240 | return static_cast<unsigned char>(c) < 0x20; |
| 241 | }); |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * @brief Sanitize a filename by stripping any path components. |
no test coverage detected