MXS-2859: Treat newlines in strings as errors

Allowing raw newlines in string values breaks configuration serialization.
This commit is contained in:
Markus Mäkelä 2020-01-30 10:44:00 +02:00
parent f53faba795
commit f6d848d58c
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -2129,6 +2129,21 @@ static bool validate_object_json(json_t* json,
if (is_valid_resource_body(json))
{
if (json_t* parameters = mxs_json_pointer(json, MXS_JSON_PTR_PARAMETERS))
{
const char* key;
json_t* value;
json_object_foreach(parameters, key, value)
{
if (json_is_string(value) && strchr(json_string_value(value), '\n'))
{
config_runtime_error("Parameter '%s' contains unescaped newlines", key);
return false;
}
}
}
if (!(value = mxs_json_pointer(json, MXS_JSON_PTR_ID)))
{
config_runtime_error("Value not found: '%s'", MXS_JSON_PTR_ID);