summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorAxel Duch <axel.duch@nginx.com>2020-07-04 03:24:07 +0100
committerAxel Duch <axel.duch@nginx.com>2020-07-04 03:24:07 +0100
commita9a21f6fe41f4da4c1dcf2d9b35287d67b1fa4d1 (patch)
treedec31a1e0b38f64fb266349fce4f2210394de4d9 /src/nxt_conf_validation.c
parent9bd6baefaee3a3e9b8dfe6427404512c9a66c969 (diff)
downloadunit-a9a21f6fe41f4da4c1dcf2d9b35287d67b1fa4d1.tar.gz
unit-a9a21f6fe41f4da4c1dcf2d9b35287d67b1fa4d1.tar.bz2
Router: route patterns multi wildcards support.
Diffstat (limited to '')
-rw-r--r--src/nxt_conf_validation.c44
1 files changed, 5 insertions, 39 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index c4f78608..f34712bd 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -1346,15 +1346,8 @@ static nxt_int_t
nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value)
{
- u_char ch;
nxt_str_t pattern;
- nxt_uint_t i, first, last;
-
- enum {
- sw_none,
- sw_side,
- sw_middle
- } state;
+ nxt_uint_t i, first;
if (nxt_conf_type(value) != NXT_CONF_STRING) {
return nxt_conf_vldt_error(vldt, "The \"match\" patterns for \"host\", "
@@ -1368,38 +1361,11 @@ nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
}
first = (pattern.start[0] == '!');
- last = pattern.length - 1;
- state = sw_none;
-
- for (i = first; i != pattern.length; i++) {
-
- ch = pattern.start[i];
-
- if (ch != '*') {
- continue;
- }
-
- switch (state) {
- case sw_none:
- state = (i == first) ? sw_side : sw_middle;
- break;
-
- case sw_side:
- if (i == last) {
- if (last - first != 1) {
- break;
- }
-
- return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
- "not contain double \"*\" markers.");
- }
-
- /* Fall through. */
- case sw_middle:
- return nxt_conf_vldt_error(vldt, "The \"match\" patterns can "
- "either contain \"*\" markers at "
- "the sides or only one in the middle.");
+ for (i = first; i < pattern.length; i++) {
+ if (pattern.start[i] == '*' && pattern.start[i + 1] == '*') {
+ return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
+ "not contain double \"*\" markers.");
}
}