]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http: add the urlp_val ACL match
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Jul 2012 05:51:48 +0000 (07:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Jul 2012 05:55:32 +0000 (07:55 +0200)
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
src/proto_http.c

index 66abe40fbab9c2bb3f7cceb0384831df5a2ae865..d13ab3a2d96db324f2ca914ee7f5903caaef6943 100644 (file)
@@ -8342,6 +8342,12 @@ urlp_sub(<name>) <string>
   can be used to detect particular patterns in query strings for example. See
   also "path_sub" and other "urlp_" criteria.
 
+urlp_val(<name>) <integer>
+  Returns true when the URL parameter "<name>" 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
 ---------------------
index 7e1d738d87163913432b69776a86246821f2d014..4a02f9160417f6ca865e2b54429641155456a050 100644 (file)
@@ -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 },
 }};