MXS_MODULE_PARAM_REGEX and QUOTED_STRING now accept non-enclosed values
This is for backwards compatibility to allow current modules to use the automatically compiled regex parameters. The enforcement should be restored in a later version. A warning is output for every non- enclosed regex. Similar changes are also applied for QUOTED_STRING.
This commit is contained in:
@ -163,7 +163,7 @@ static bool check_config_objects(CONFIG_CONTEXT *context);
|
|||||||
static int maxscale_getline(char** dest, int* size, FILE* file);
|
static int maxscale_getline(char** dest, int* size, FILE* file);
|
||||||
static bool check_first_last_char(const char* string, char expected);
|
static bool check_first_last_char(const char* string, char expected);
|
||||||
static void remove_first_last_char(char* value);
|
static void remove_first_last_char(char* value);
|
||||||
static bool test_regex_string_validity(const char* regex_string);
|
static bool test_regex_string_validity(const char* regex_string, const char* key);
|
||||||
static bool compile_regex_string(const char* regex_string, bool jit_enabled, uint32_t options,
|
static bool compile_regex_string(const char* regex_string, bool jit_enabled, uint32_t options,
|
||||||
pcre2_code** output_code, uint32_t* output_capcount);
|
pcre2_code** output_code, uint32_t* output_capcount);
|
||||||
|
|
||||||
@ -3633,8 +3633,19 @@ void config_fix_param(const MXS_MODULE_PARAM *params, MXS_CONFIG_PARAMETER *p)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MXS_MODULE_PARAM_QUOTEDSTRING:
|
case MXS_MODULE_PARAM_QUOTEDSTRING:
|
||||||
case MXS_MODULE_PARAM_REGEX:
|
// Remove *if* once '" .. "' is no longer optional
|
||||||
|
if (check_first_last_char(p->value, '"'))
|
||||||
|
{
|
||||||
remove_first_last_char(p->value);
|
remove_first_last_char(p->value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MXS_MODULE_PARAM_REGEX:
|
||||||
|
// Remove *if* once '/ .. /' is no longer optional
|
||||||
|
if (check_first_last_char(p->value, '/'))
|
||||||
|
{
|
||||||
|
remove_first_last_char(p->value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -3734,7 +3745,20 @@ bool config_param_is_valid(const MXS_MODULE_PARAM *params, const char *key,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MXS_MODULE_PARAM_QUOTEDSTRING:
|
case MXS_MODULE_PARAM_QUOTEDSTRING:
|
||||||
valid = check_first_last_char(value, '"');
|
if (*value)
|
||||||
|
{
|
||||||
|
valid = true;
|
||||||
|
if (!check_first_last_char(value, '"'))
|
||||||
|
{
|
||||||
|
// Change warning to valid=false once quotes are no longer optional
|
||||||
|
MXS_WARNING("Missing quotes (\") around a quoted string is deprecated: '%s=%s'.",
|
||||||
|
key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MXS_MODULE_PARAM_REGEX:
|
||||||
|
valid = test_regex_string_validity(value, key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MXS_MODULE_PARAM_ENUM:
|
case MXS_MODULE_PARAM_ENUM:
|
||||||
@ -3814,10 +3838,6 @@ bool config_param_is_valid(const MXS_MODULE_PARAM *params, const char *key,
|
|||||||
valid = check_path_parameter(¶ms[i], value);
|
valid = check_path_parameter(¶ms[i], value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MXS_MODULE_PARAM_REGEX:
|
|
||||||
valid = test_regex_string_validity(value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
MXS_ERROR("Unexpected module parameter type: %d", params[i].type);
|
MXS_ERROR("Unexpected module parameter type: %d", params[i].type);
|
||||||
ss_dassert(false);
|
ss_dassert(false);
|
||||||
@ -4121,15 +4141,24 @@ static bool compile_regex_string(const char* regex_string, bool jit_enabled,
|
|||||||
* @return True if compilation succeeded, false if string is invalid or cannot
|
* @return True if compilation succeeded, false if string is invalid or cannot
|
||||||
* be compiled.
|
* be compiled.
|
||||||
*/
|
*/
|
||||||
static bool test_regex_string_validity(const char* regex_string)
|
static bool test_regex_string_validity(const char* regex_string, const char* key)
|
||||||
{
|
{
|
||||||
if (!check_first_last_char(regex_string, '/'))
|
if (*regex_string == '\0')
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char regex_copy[strlen(regex_string) + 1];
|
char regex_copy[strlen(regex_string) + 1];
|
||||||
strcpy(regex_copy, regex_string);
|
strcpy(regex_copy, regex_string);
|
||||||
|
if (!check_first_last_char(regex_string, '/'))
|
||||||
|
{
|
||||||
|
//return false; // Uncomment this line once '/ .. /' is no longer optional
|
||||||
|
MXS_WARNING("Missing slashes (/) around a regular expression is deprecated: '%s=%s'.",
|
||||||
|
key, regex_string);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
remove_first_last_char(regex_copy);
|
remove_first_last_char(regex_copy);
|
||||||
|
}
|
||||||
|
|
||||||
pcre2_code* code;
|
pcre2_code* code;
|
||||||
uint32_t capcount;
|
uint32_t capcount;
|
||||||
|
Reference in New Issue
Block a user