CLEANUP: regex: remove outdated support for regex actions
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.
diff --git a/include/common/regex.h b/include/common/regex.h
index 066f07e..cecfbd9 100644
--- a/include/common/regex.h
+++ b/include/common/regex.h
@@ -61,18 +61,9 @@
#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 @@
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.
*/
diff --git a/src/regex.c b/src/regex.c
index 6b86b03..195f9a7 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -124,33 +124,6 @@
}
-/* 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.