summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nxt_conf_validation.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index ee87b0f6..e2e1b89e 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -741,6 +741,12 @@ nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
nxt_str_t pattern;
nxt_uint_t i, first, last;
+ enum {
+ sw_none,
+ sw_side,
+ sw_middle
+ } state;
+
if (nxt_conf_type(value) != NXT_CONF_STRING) {
return nxt_conf_vldt_error(vldt,
"The \"match\" patterns must be strings.");
@@ -754,17 +760,32 @@ 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;
}
- if (i != first && i != last) {
- return nxt_conf_vldt_error(vldt, "The \"match\" patterns can only "
- "contain \"*\" markers at the sides.");
+ switch (state) {
+ case sw_none:
+ state = (i == first) ? sw_side : sw_middle;
+ break;
+
+ case sw_side:
+ if (i == last) {
+ break;
+ }
+
+ /* 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.");
}
}