MCPcopy Create free account
hub / github.com/MITK/MITK / ValidatePropertyKey

Function ValidatePropertyKey

Modules/RESTAPI/src/mitkDataStorageController.cpp:233–242  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

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.

Calls 4

emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected