]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: regex: remove outdated support for regex actions
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Jun 2020 15:17:13 +0000 (17:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 2 Jun 2020 15:17:13 +0000 (17:17 +0200)
The support for reqrep and friends was removed in 2.1 but the
chain_regex() function and the "action" field in the regex struct
was still there. This patch removes them.

One point worth mentioning though. There is a check_replace_string()
function whose purpose was to validate the replacement strings passed
to reqrep. It should also be used for other replacement regex, but is
never called. Callers of exp_replace() should be checked and a call to
this function should be added to detect the error early.

include/common/regex.h
src/regex.c

index 066f07edda8f82675efd921ef2aae6887fcdd630..cecfbd93c033e8bfa08e94d5c2d68f1f20dce065 100644 (file)
@@ -61,18 +61,9 @@ struct my_regex {
 #endif
 };
 
-/* what to do when a header matches a regex */
-#define ACT_ALLOW      0       /* allow the request */
-#define ACT_REPLACE    1       /* replace the matching header */
-#define ACT_REMOVE     2       /* remove the matching header */
-#define ACT_DENY       3       /* deny the request */
-#define ACT_PASS       4       /* pass this header without allowing or denying the request */
-#define ACT_TARPIT     5       /* tarpit the connection matching this request */
-
 struct hdr_exp {
     struct hdr_exp *next;
     struct my_regex *preg;             /* expression to look for */
-    int action;                                /* ACT_ALLOW, ACT_REPLACE, ACT_REMOVE, ACT_DENY */
     const char *replace;               /* expression to set instead */
     void *cond;                                /* a possible condition or NULL */
 };
@@ -92,8 +83,6 @@ extern THREAD_LOCAL regmatch_t pmatch[MAX_MATCH];
 struct my_regex *regex_comp(const char *str, int cs, int cap, char **err);
 int exp_replace(char *dst, unsigned int dst_size, char *src, const char *str, const regmatch_t *matches);
 const char *check_replace_string(const char *str);
-const char *chain_regex(struct hdr_exp **head, struct my_regex *preg,
-                       int action, const char *replace, void *cond);
 
 /* If the function doesn't match, it returns false, else it returns true.
  */
index 6b86b037e7c9f39ba4471206abcf457c5c7f920d..195f9a79d99249ab0c5e0bd5b1122e788db5d50b 100644 (file)
@@ -124,33 +124,6 @@ const char *check_replace_string(const char *str)
 }
 
 
-/* returns the pointer to an error in the replacement string, or NULL if OK */
-const char *chain_regex(struct hdr_exp **head, struct my_regex *preg,
-                       int action, const char *replace, void *cond)
-{
-       struct hdr_exp *exp;
-
-       if (replace != NULL) {
-               const char *err;
-               err = check_replace_string(replace);
-               if (err)
-                       return err;
-       }
-
-       while (*head != NULL)
-               head = &(*head)->next;
-
-       exp = calloc(1, sizeof(*exp));
-
-       exp->preg = preg;
-       exp->replace = replace;
-       exp->action = action;
-       exp->cond = cond;
-       *head = exp;
-
-       return NULL;
-}
-
 /* This function apply regex. It take const null terminated char as input.
  * If the function doesn't match, it returns false, else it returns true.
  * When it is compiled with JIT, this function execute strlen on the subject.