diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp_config_keywords.c | 41 | ||||
| -rw-r--r-- | src/tests/broken_conf_mutually_exclusive.phpt | 2 | ||||
| -rw-r--r-- | src/tests/broken_conf_mutually_exclusive3.phpt | 2 | ||||
| -rw-r--r-- | src/tests/broken_conf_mutually_exclusive5.phpt | 2 |
4 files changed, 19 insertions, 28 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index 416aaef..b1b22b5 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -182,36 +182,27 @@ int parse_disabled_functions(char *line) { | |||
| 182 | return ret; | 182 | return ret; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | if (df->value && df->value_r) { | 185 | #define MUTUALLY_EXCLUSIVE(X, Y, STR1, STR2) \ |
| 186 | sp_log_err("config", | 186 | if (X && Y) { \ |
| 187 | "Invalid configuration line: 'sp.disabled_functions%s':" | 187 | sp_log_err("config", \ |
| 188 | "'.value' and '.regexp' are mutually exclusives on line %zu.", | 188 | "Invalid configuration line: 'sp.disabled_functions%s': " \ |
| 189 | line, sp_line_no); | 189 | "'.%s' and '.%s' are mutually exclusive on line %zu.", \ |
| 190 | return -1; | 190 | line, STR1, STR2, sp_line_no); \ |
| 191 | } else if (df->r_function && df->function) { | 191 | return 1;\ |
| 192 | sp_log_err("config", | 192 | } |
| 193 | "Invalid configuration line: 'sp.disabled_functions%s': " | 193 | |
| 194 | "'.r_function' and '.function' are mutually exclusive on line %zu.", | 194 | MUTUALLY_EXCLUSIVE(df->value, df->value_r, "value", "regexp"); |
| 195 | line, sp_line_no); | 195 | MUTUALLY_EXCLUSIVE(df->r_function, df->function, "r_function", "function"); |
| 196 | return -1; | 196 | MUTUALLY_EXCLUSIVE(df->filename, df->r_filename, "r_filename", "filename"); |
| 197 | } else if (df->r_filename && df->filename) { | 197 | MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "r_ret", "ret"); |
| 198 | sp_log_err("config", | 198 | #undef MUTUALLY_EXCLUSIVE |
| 199 | "Invalid configuration line: 'sp.disabled_functions%s':" | 199 | |
| 200 | "'.r_filename' and '.filename' are mutually exclusive on line %zu.", | 200 | if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) { |
| 201 | line, sp_line_no); | ||
| 202 | return -1; | ||
| 203 | } else if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) { | ||
| 204 | sp_log_err("config", | 201 | sp_log_err("config", |
| 205 | "Invalid configuration line: 'sp.disabled_functions%s':" | 202 | "Invalid configuration line: 'sp.disabled_functions%s':" |
| 206 | "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.", | 203 | "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.", |
| 207 | line, sp_line_no); | 204 | line, sp_line_no); |
| 208 | return -1; | 205 | return -1; |
| 209 | } else if (df->r_ret && df->ret) { | ||
| 210 | sp_log_err("config", | ||
| 211 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 212 | "'.r_ret' and '.ret' are mutually exclusive on line %zu.", | ||
| 213 | line, sp_line_no); | ||
| 214 | return -1; | ||
| 215 | } else if ((df->r_ret || df->ret) && (df->r_param || df->param)) { | 206 | } else if ((df->r_ret || df->ret) && (df->r_param || df->param)) { |
| 216 | sp_log_err("config", | 207 | sp_log_err("config", |
| 217 | "Invalid configuration line: 'sp.disabled_functions%s':" | 208 | "Invalid configuration line: 'sp.disabled_functions%s':" |
diff --git a/src/tests/broken_conf_mutually_exclusive.phpt b/src/tests/broken_conf_mutually_exclusive.phpt index 7bfd313..5897770 100644 --- a/src/tests/broken_conf_mutually_exclusive.phpt +++ b/src/tests/broken_conf_mutually_exclusive.phpt | |||
| @@ -6,4 +6,4 @@ Broken configuration | |||
| 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive.ini |
| 7 | --FILE-- | 7 | --FILE-- |
| 8 | --EXPECT-- | 8 | --EXPECT-- |
| 9 | [snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").value_r("^id$").drop();':'.value' and '.regexp' are mutually exclusives on line 1. \ No newline at end of file | 9 | [snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").value_r("^id$").drop();': '.value' and '.regexp' are mutually exclusive on line 1. |
diff --git a/src/tests/broken_conf_mutually_exclusive3.phpt b/src/tests/broken_conf_mutually_exclusive3.phpt index 3be561c..7b94318 100644 --- a/src/tests/broken_conf_mutually_exclusive3.phpt +++ b/src/tests/broken_conf_mutually_exclusive3.phpt | |||
| @@ -6,4 +6,4 @@ Broken configuration | |||
| 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive3.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive3.ini |
| 7 | --FILE-- | 7 | --FILE-- |
| 8 | --EXPECT-- | 8 | --EXPECT-- |
| 9 | [snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").filename_r("^id$").filename("pouet.txt").drop();':'.r_filename' and '.filename' are mutually exclusive on line 1. \ No newline at end of file | 9 | [snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").filename_r("^id$").filename("pouet.txt").drop();': '.r_filename' and '.filename' are mutually exclusive on line 1. |
diff --git a/src/tests/broken_conf_mutually_exclusive5.phpt b/src/tests/broken_conf_mutually_exclusive5.phpt index 9ebc930..0a9e0fd 100644 --- a/src/tests/broken_conf_mutually_exclusive5.phpt +++ b/src/tests/broken_conf_mutually_exclusive5.phpt | |||
| @@ -6,4 +6,4 @@ Broken configuration | |||
| 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive5.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive5.ini |
| 7 | --FILE-- | 7 | --FILE-- |
| 8 | --EXPECT-- | 8 | --EXPECT-- |
| 9 | [snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().ret_r("^0$");':'.r_ret' and '.ret' are mutually exclusive on line 1. \ No newline at end of file | 9 | [snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().ret_r("^0$");': '.r_ret' and '.ret' are mutually exclusive on line 1. |
