From 637016b224d55896e647fbc1c93ce3eb64bc0dee Mon Sep 17 00:00:00 2001 From: Bernd Machenschalk Date: Wed, 29 Sep 2021 13:37:25 +0200 Subject: [PATCH] scheduler: make regex negation conform to standard, i.e. using '(?!regex)' --- sched/plan_class_spec.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sched/plan_class_spec.cpp b/sched/plan_class_spec.cpp index 1a7ac9c7828..7c4525e9e3c 100644 --- a/sched/plan_class_spec.cpp +++ b/sched/plan_class_spec.cpp @@ -33,13 +33,17 @@ int REGEX_CLAUSE::init(const char* p) { present = true; negate = false; expr = p; - if (*p == '!') { - p++; + if (!strncmp(p,"(?!",3) && p[strlen(p)-1] == ')') { + p += 3; + p[strlen(p)-1] = '\0'; // don't parse trailing ')' negate = true; } if (regcomp(®ex, p, REG_EXTENDED|REG_NOSUB) ) { return ERR_XML_PARSE; } + if (negate) { + p[strlen(p)] = ')'; // restore trailing ')' + } return 0; }