From a9fddca778f8aea16687699094fa486ec713ba81 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 31 Jul 2012 07:51:48 +0200 Subject: [PATCH] MINOR: http: add the urlp_val ACL match It's derived from other urlp_* matches, but there was no way to check for an integer value and it seems like it's significantly used. --- doc/configuration.txt | 6 ++++++ src/proto_http.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/doc/configuration.txt b/doc/configuration.txt index 66abe40fb..d13ab3a2d 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -8342,6 +8342,12 @@ urlp_sub() can be used to detect particular patterns in query strings for example. See also "path_sub" and other "urlp_" criteria. +urlp_val() + Returns true when the URL parameter "" starts with a number matching + the values or ranges specified. Note that the absence of the parameter does + not match anything. Integers are unsigned so it is not possible to match + negative data. + 7.6. Pre-defined ACLs --------------------- diff --git a/src/proto_http.c b/src/proto_http.c index 7e1d738d8..4a02f9160 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -8548,6 +8548,23 @@ smp_fetch_url_param(struct proxy *px, struct session *l4, void *l7, unsigned int return 1; } +/* Return the signed integer value for the specified url parameter (see url_param + * above). + */ +static int +smp_fetch_url_param_val(struct proxy *px, struct session *l4, void *l7, unsigned int opt, + const struct arg *args, struct sample *smp) +{ + int ret = smp_fetch_url_param(px, l4, l7, opt, args, smp); + + if (ret > 0) { + smp->type = SMP_T_UINT; + smp->data.uint = strl2ic(smp->data.str.str, smp->data.str.len); + } + + return ret; +} + /* This function is used to validate the arguments passed to any "hdr" fetch * keyword. These keywords support an optional positive or negative occurrence * number. We must ensure that the number is greater than -MAX_HDR_HISTORY. It @@ -8670,6 +8687,7 @@ static struct acl_kw_list acl_kws = {{ },{ { "urlp_len", acl_parse_int, smp_fetch_url_param, acl_match_len, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) }, { "urlp_reg", acl_parse_reg, smp_fetch_url_param, acl_match_reg, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) }, { "urlp_sub", acl_parse_str, smp_fetch_url_param, acl_match_sub, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) }, + { "urlp_val", acl_parse_int, smp_fetch_url_param_val, acl_match_int, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) }, { NULL, NULL, NULL, NULL }, }};