mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
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.
This commit is contained in:
parent
530ba38a70
commit
39bd740d00
@ -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.
|
||||
*/
|
||||
|
27
src/regex.c
27
src/regex.c
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user