From: Alan T. DeKok Date: Thu, 16 Nov 2023 13:05:14 +0000 (-0500) Subject: move xlat printing to new function syntax X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f118f1c2b5beab8338dad8b227bfa43f05d7c95;p=thirdparty%2Ffreeradius-server.git move xlat printing to new function syntax --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index e388779ebc2..82c3ba771fc 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -211,7 +211,7 @@ static fr_slen_t xlat_expr_print_unary(fr_sbuff_t *out, xlat_exp_t const *node, size_t at_in = fr_sbuff_used_total(out); FR_SBUFF_IN_STRCPY_RETURN(out, fr_tokens[node->call.func->token]); - xlat_print_node(out, node->call.args, xlat_exp_head(node->call.args), e_rules); + xlat_print_node(out, node->call.args, xlat_exp_head(node->call.args), e_rules, 0); return fr_sbuff_used_total(out) - at_in; } @@ -224,7 +224,7 @@ static fr_slen_t xlat_expr_print_binary(fr_sbuff_t *out, xlat_exp_t const *node, fr_assert(child != NULL); FR_SBUFF_IN_CHAR_RETURN(out, '('); - xlat_print_node(out, node->call.args, child, e_rules); /* prints a space after the first argument */ + xlat_print_node(out, node->call.args, child, e_rules, 0); /* prints a space after the first argument */ FR_SBUFF_IN_STRCPY_RETURN(out, fr_tokens[node->call.func->token]); FR_SBUFF_IN_CHAR_RETURN(out, ' '); @@ -232,7 +232,7 @@ static fr_slen_t xlat_expr_print_binary(fr_sbuff_t *out, xlat_exp_t const *node, child = xlat_exp_next(node->call.args, child); fr_assert(child != NULL); - xlat_print_node(out, node->call.args, child, e_rules); + xlat_print_node(out, node->call.args, child, e_rules, 0); FR_SBUFF_IN_CHAR_RETURN(out, ')'); @@ -534,7 +534,7 @@ static fr_slen_t xlat_expr_print_regex(fr_sbuff_t *out, xlat_exp_t const *node, fr_assert(child != NULL); FR_SBUFF_IN_CHAR_RETURN(out, '('); - xlat_print_node(out, node->call.args, child, e_rules); + xlat_print_node(out, node->call.args, child, e_rules, 0); /* * A space is printed after the first argument only if @@ -868,7 +868,7 @@ static fr_slen_t xlat_expr_print_nary(fr_sbuff_t *out, xlat_exp_t const *node, v fr_assert(head != NULL); xlat_exp_foreach(head, child) { - xlat_print_node(out, head, child, e_rules); + xlat_print_node(out, head, child, e_rules, 0); if (!xlat_exp_next(head, child)) break; @@ -1597,7 +1597,7 @@ static fr_slen_t xlat_expr_print_exists(fr_sbuff_t *out, xlat_exp_t const *node, if (inst->xlat) { xlat_print(out, inst->xlat, e_rules); } else { - xlat_print_node(out, node->call.args, xlat_exp_head(node->call.args), e_rules); + xlat_print_node(out, node->call.args, xlat_exp_head(node->call.args), e_rules, 0); } return fr_sbuff_used_total(out) - at_in; diff --git a/src/lib/unlang/xlat_priv.h b/src/lib/unlang/xlat_priv.h index a75a844b463..775ae05c3c2 100644 --- a/src/lib/unlang/xlat_priv.h +++ b/src/lib/unlang/xlat_priv.h @@ -339,7 +339,7 @@ int xlat_tokenize_function_args(xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rules_t const *t_rules); ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t const *node, - fr_sbuff_escape_rules_t const *e_rules); + fr_sbuff_escape_rules_t const *e_rules, char c); #ifdef __cplusplus } diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 617b38cd53a..f5a0dc86e79 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -1360,7 +1360,7 @@ void xlat_debug_head(xlat_exp_head_t const *head) } ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t const *node, - fr_sbuff_escape_rules_t const *e_rules) + fr_sbuff_escape_rules_t const *e_rules, char c) { ssize_t slen; size_t at_in = fr_sbuff_used_total(out); @@ -1374,7 +1374,10 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t xlat_print(out, node->group, fr_value_escape_by_quote[node->quote]); if (node->quote != T_BARE_WORD) FR_SBUFF_IN_CHAR_RETURN(out, fr_token_quote[node->quote]); - if (xlat_exp_next(head, node)) FR_SBUFF_IN_CHAR_RETURN(out, ' '); /* Add ' ' between args */ + if (xlat_exp_next(head, node)) { + if (c) FR_SBUFF_IN_CHAR_RETURN(out, c); + FR_SBUFF_IN_CHAR_RETURN(out, ' '); /* Add ' ' between args */ + } goto done; case XLAT_BOX: @@ -1468,8 +1471,8 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t /* * Now print %(...) or %{...} */ - if ((node->type == XLAT_FUNC) && (node->call.func->input_type == XLAT_INPUT_ARGS)) { - FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, "%("); + if ((node->type == XLAT_FUNC) || (node->type == XLAT_FUNC_UNRESOLVED)) { + FR_SBUFF_IN_CHAR_RETURN(out, '%'); /* then the name */ close = ')'; } else { FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, "%{"); @@ -1496,21 +1499,20 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t case XLAT_FUNC: FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->call.func->name); - FR_SBUFF_IN_CHAR_RETURN(out, ':'); + FR_SBUFF_IN_CHAR_RETURN(out, '('); - if (xlat_exp_head(node->call.args)) { - slen = xlat_print(out, node->call.args, &xlat_escape); - if (slen < 0) return slen; - } - break; + goto print_args; case XLAT_FUNC_UNRESOLVED: FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->fmt); - FR_SBUFF_IN_CHAR_RETURN(out, ':'); + FR_SBUFF_IN_CHAR_RETURN(out, '('); + print_args: if (xlat_exp_head(node->call.args)) { - slen = xlat_print(out, node->call.args, &xlat_escape); - if (slen < 0) return slen; + xlat_exp_foreach(node->call.args, child) { + slen = xlat_print_node(out, node->call.args, child, &xlat_escape, ','); + if (slen < 0) return slen; + } } break; @@ -1539,7 +1541,7 @@ ssize_t xlat_print(fr_sbuff_t *out, xlat_exp_head_t const *head, fr_sbuff_escape size_t at_in = fr_sbuff_used_total(out); xlat_exp_foreach(head, node) { - slen = xlat_print_node(out, head, node, e_rules); + slen = xlat_print_node(out, head, node, e_rules, 0); if (slen < 0) return slen - (fr_sbuff_used_total(out) - at_in); } diff --git a/src/tests/unit/condition/base.txt b/src/tests/unit/condition/base.txt index 5fc4f8aabcf..70aa7505e59 100644 --- a/src/tests/unit/condition/base.txt +++ b/src/tests/unit/condition/base.txt @@ -62,7 +62,7 @@ match ERROR offset 5: Invalid operator # sillyness is OK, but cleaned up. condition ((((((ok)))))) -match %{rcode:'ok'} +match %rcode('ok') # # Extra braces get squashed @@ -71,10 +71,10 @@ condition (&User-Name == &User-Password) match (&User-Name == &User-Password) condition (!ok) -match !%{rcode:'ok'} +match !%rcode('ok') condition !(ok) -match !%{rcode:'ok'} +match !%rcode('ok') condition !!ok match ERROR offset 2: Double operator is invalid @@ -83,7 +83,7 @@ match ERROR offset 2: Double operator is invalid # @todo - peephole - do optimization to get rid of double negation? # condition !(!ok) -match !!%{rcode:'ok'} +match !!%rcode('ok') # # These next two are identical after normalization @@ -112,15 +112,15 @@ match ((a == b) || (c == d)) #match ERROR offset 23: Unexpected closing brace condition (handled && (&Packet-Type == Access-Challenge)) -match (%{rcode:'handled'} && (&Packet-Type == Access-Challenge)) +match (%rcode('handled') && (&Packet-Type == Access-Challenge)) # This is OK, without the braces condition handled && &Packet-Type == Access-Challenge -match (%{rcode:'handled'} && (&Packet-Type == Access-Challenge)) +match (%rcode('handled') && (&Packet-Type == Access-Challenge)) # and this, though it's not a good idea. condition handled &&&Packet-Type == Access-Challenge -match (%{rcode:'handled'} && (&Packet-Type == Access-Challenge)) +match (%rcode('handled') && (&Packet-Type == Access-Challenge)) condition &reply == &request match ERROR offset 1: Cannot use list references in condition @@ -224,7 +224,7 @@ match (&Session-Timeout == '10') # Except for dates, which can be humanly readable! # This one is be an expansion, so it's left as-is. condition &Event-Timestamp == "January 1, 2012 %{blah}" -match (&Event-Timestamp == %(cast:string "January 1, 2012 %{blah}")) +match (&Event-Timestamp == %cast(string, "January 1, 2012 %{blah}")) # This one is NOT an expansion, so it's parsed into normal form condition &Event-Timestamp == 'January 1, 2012' @@ -247,23 +247,23 @@ match (&NAS-Port == X) condition (ipaddr)127.0.0.1 == "127.0.0.1" match true -condition (ipaddr)127.0.0.1 == "%{md4: 127.0.0.1}" -match (127.0.0.1 == %(cast:string "%{md4: 127.0.0.1}")) +condition (ipaddr)127.0.0.1 == "%md4(' 127.0.0.1')" +match (127.0.0.1 == %cast(string, "%md4(' 127.0.0.1')")) # # Bare %{...} is allowed. # -condition (ipaddr)127.0.0.1 == %{md4:127.0.0.1} -match (127.0.0.1 == %{md4:127.0.0.1}) +condition (ipaddr)127.0.0.1 == %md4('127.0.0.1') +match (127.0.0.1 == %md4('127.0.0.1')) -condition (ipaddr)127.0.0.1 == %{md4: SELECT user FROM table WHERE user='%{User-Name}'} -match (127.0.0.1 == %{md4: SELECT user FROM table WHERE user='%{User-Name}'}) +condition (ipaddr)127.0.0.1 == %md4("SELECT user FROM table WHERE user='%{User-Name}'") +match (127.0.0.1 == %md4("SELECT user FROM table WHERE user='%{User-Name}'")) condition (ether) 00:11:22:33:44:55 == "00:11:22:33:44:55" match true -condition (ether) 00:11:22:33:44:55 == "%{md4:00:11:22:33:44:55}" -match (00:11:22:33:44:55 == %(cast:string "%{md4:00:11:22:33:44:55}")) +condition (ether) 00:11:22:33:44:55 == "%md4('00:11:22:33:44:55')" +match (00:11:22:33:44:55 == %cast(string, "%md4('00:11:22:33:44:55')")) condition (ether) 00:XX:22:33:44:55 == 00:11:22:33:44:55 match ERROR offset 12: Missing separator, expected ':' @@ -316,11 +316,11 @@ match true condition ('foo' == 'foo') match true -condition ("foo" == "%{md4: foo}") -match ("foo" == %(cast:string "%{md4: foo}")) +condition ("foo" == "%md4(' foo')") +match ("foo" == %cast(string, "%md4(' foo')")) -condition ("foo bar" == "%{md4: foo}") -match ("foo bar" == %(cast:string "%{md4: foo}")) +condition ("foo bar" == "%md4(' foo')") +match ("foo bar" == %cast(string, "%md4(' foo')")) condition ("foo" == "bar") match false @@ -336,8 +336,8 @@ match false condition (&User-Name == "bob") match (&User-Name == "bob") -condition (&User-Name == "%{md4: blah}") -match (&User-Name == %(cast:string "%{md4: blah}")) +condition (&User-Name == "%md4(' blah')") +match (&User-Name == %cast(string, "%md4(' blah')")) condition (ipaddr)127.0.0.1 == 2130706433 match true @@ -392,13 +392,13 @@ match ERROR offset 1: Unexpected text - attribute names must prefixed with '&' # Module return codes are OK # condition (ok) -match %{rcode:'ok'} +match %rcode('ok') condition (handled) -match %{rcode:'handled'} +match %rcode('handled') condition (fail) -match %{rcode:'fail'} +match %rcode('fail') condition ("a") match "a" @@ -421,8 +421,8 @@ condition (string)"foo" == &User-Name match ("foo" == &User-Name) # This used to be expr, but expr isn't a builtin, so it failed... -condition (integer)"%{md4: 1 + 1}" < &NAS-Port -match (%(cast:uint32 "%{md4: 1 + 1}") < &NAS-Port) +condition (integer)"%md4(' 1 + 1')" < &NAS-Port +match (%cast(uint32, "%md4(' 1 + 1')") < &NAS-Port) # # The string gets parsed as an IP address. @@ -456,7 +456,7 @@ match ((ipaddr)&PMIP6-Home-IPv4-HoA == &Framed-IP-Address) # but these are allowed condition (ether)&Tmp-uint64-0 == "%interpreter('foo')" -match ((ether)&Tmp-uint64-0 == %(cast:string "%(interpreter:'foo')")) +match ((ether)&Tmp-uint64-0 == %cast(string, "%interpreter('foo')")) condition (ipaddr)&Filter-Id == &Framed-IP-Address match ((ipaddr)&Filter-Id == &Framed-IP-Address) @@ -492,11 +492,11 @@ match &Foo-Bar # data &Acct-Input-Octets > &Session-Timeout # condition &Acct-Input-Octets > "%{Session-Timeout}" -match (&Acct-Input-Octets > %(cast:string "%{Session-Timeout}")) +match (&Acct-Input-Octets > %cast(string, "%{Session-Timeout}")) # Separate types aren't optimized condition &Acct-Input-Octets-64 > "%{Session-Timeout}" -match (&Acct-Input-Octets-64 > %(cast:string "%{Session-Timeout}")) +match (&Acct-Input-Octets-64 > %cast(string, "%{Session-Timeout}")) # # Parse OIDs into known attributes, where possible. diff --git a/src/tests/unit/xlat/base.txt b/src/tests/unit/xlat/base.txt index 54c9c1fa6a2..ab971df0103 100644 --- a/src/tests/unit/xlat/base.txt +++ b/src/tests/unit/xlat/base.txt @@ -67,8 +67,8 @@ match ERROR offset 4: Missing closing brace xlat %{Tunnel-Password} match %{Tunnel-Password} -xlat %{test:bar} -match %{test:bar} +xlat %test('bar') +match %test('bar') xlat %{Tunnel-Password} match %{Tunnel-Password} @@ -121,8 +121,8 @@ match \"%{reply.Vendor-Specific.3GPP.IMSI[2]}\" xlat /([A-Z0-9\\-]*)_%{Calling-Station-Id}/ match /([A-Z0-9\\-]*)_%{Calling-Station-Id}/ -xlat %(length:) -match %(length:) +xlat %length() +match %length() xlat %(length: match ERROR offset 10: Missing closing brace @@ -137,7 +137,7 @@ xlat \"%t\t%{NAS-IP-Address}\" match \"%t\t%{NAS-IP-Address}\" xlat \"foo %test('foo')\" -match \"foo %{test:'foo'}\" +match \"foo %test('foo')\" # # Alternations @@ -163,8 +163,8 @@ match ERROR offset 3: Missing expansion function xlat %{:bar} match ERROR offset 3: Missing expansion function -xlat %{foo: bar} -match ERROR offset 3: Unresolved expansion functions are not allowed here +xlat %foo(' bar') +match ERROR offset 2: Unresolved expansion functions are not allowed here xlat %{[} match ERROR offset 3: Missing attribute name @@ -242,16 +242,16 @@ xlat_argv echo hello %{Tmp-String-0}:1234 world match [0]{ echo }, [1]{ hello }, [2]{ %{Tmp-String-0}:1234 }, [3]{ world } xlat %(debug: 5) -match %(debug: 5) +match %debug(, 5) xlat %(debug: "foo") -match %(debug: "foo") +match %debug(, "foo") # # This is correct. # xlat %(rpad:&User-Name 5 x) -match %(rpad:&User-Name 5 x) +match %rpad(&User-Name, 5, x) # # The second argument should be an integer. @@ -265,23 +265,26 @@ match ERROR offset 24: Failed parsing argument 1 as type 'uint64' # # Argument quoting # -xlat %{md5:"arg"} -match %{md5:"arg"} +xlat %md5('"arg"') +match %md5('"arg"') -xlat %{md5:"arg}"} -match %{md5:"arg}"} +xlat %md5('"arg')"} +match %md5('"arg')\"} -xlat %{md5:"arg} -match ERROR offset 12: Missing closing '"' +xlat %md5('"arg') +match %md5('"arg') -xlat %{md5:"arg\""} -match %{md5:"arg\""} +# +# @todo - ??? not sure here +# +xlat %md5('"arg\""') +match %md5('"arg\\""') xlat %{md5:'arg'} -match %{md5:'arg'} +match %md5('arg') xlat %{md5:'arg"'} -match %{md5:'arg"'} +match %md5('arg"') count match 157 diff --git a/src/tests/unit/xlat/cond_base.txt b/src/tests/unit/xlat/cond_base.txt index 49b0f81f16c..47474b1eea7 100644 --- a/src/tests/unit/xlat/cond_base.txt +++ b/src/tests/unit/xlat/cond_base.txt @@ -125,10 +125,10 @@ match Passed in 67 characters, but only parsed 66 characters # Truthy strings get omitted. # xlat_purify ('handled' && (&Packet-Type == Access-Challenge)) -match (&Packet-Type == Access-Challenge) +match (&Packet-Type == Access-Challenge) xlat_purify (handled && (&Packet-Type == Access-Challenge)) -match (%{rcode:'handled'} && (&Packet-Type == Access-Challenge)) +match (%rcode('handled') && (&Packet-Type == Access-Challenge)) # This is OK, without the braces xlat_purify 'handled' && &Packet-Type == Access-Challenge @@ -222,7 +222,7 @@ match (&Session-Timeout == '10') # This one is be an expansion, so it's left as-is. # xlat_purify &Event-Timestamp == "January 1, 2012 %{User-Name}" -match (&Event-Timestamp == %(cast:string "January 1, 2012 %{User-Name}")) +match (&Event-Timestamp == %cast(string, "January 1, 2012 %{User-Name}")) # This one is NOT an expansion, so it's parsed into normal form xlat_purify &Event-Timestamp == 'January 1 2012' @@ -249,26 +249,26 @@ match true # LHS is IPaddr, RHS is string (malformed IP address). # We can only fail this at run-time. -xlat_purify (ipaddr)127.0.0.1 == "%{md4: 127.0.0.1}" -match (127.0.0.1 == %(cast:string "%{md4: 127.0.0.1}")) +xlat_purify (ipaddr)127.0.0.1 == "%md4(' 127.0.0.1')" +match (127.0.0.1 == %cast(string, "%md4(' 127.0.0.1')")) # # Bare %{...} is allowed. # # Invalid cast from octets to ipaddr. -xlat_purify (ipaddr)127.0.0.1 == %{md4:127.0.0.1} -match (127.0.0.1 == %{md4:127.0.0.1}) +xlat_purify (ipaddr)127.0.0.1 == %md4('127.0.0.1') +match (127.0.0.1 == %md4('127.0.0.1')) xlat_purify (ipaddr)127.0.0.1 == %{md4: SELECT user FROM table WHERE user='%{User-Name}'} -match (127.0.0.1 == %{md4: SELECT user FROM table WHERE user='%{User-Name}'}) +match (127.0.0.1 == %md4( SELECT user FROM table WHERE user='%{User-Name}')) xlat_purify (ether) 00:11:22:33:44:55 == "00:11:22:33:44:55" match true # Invalid cast from octets to ether. -xlat_purify (ether)00:11:22:33:44:55 == "%{md4:00:11:22:33:44:55}" -match (00:11:22:33:44:55 == %(cast:string "%{md4:00:11:22:33:44:55}")) +xlat_purify (ether)00:11:22:33:44:55 == "%md4('00:11:22:33:44:55')" +match (00:11:22:33:44:55 == %cast(string, "%md4('00:11:22:33:44:55')")) xlat_purify (ether) 00:XX:22:33:44:55 == 00:11:22:33:44:55 match ERROR offset 12: Missing separator, expected ':' @@ -314,10 +314,10 @@ match true # # MD4 hash is not equal to other things # -xlat_purify ("foo" == "%{md4: foo}") +xlat_purify ("foo" == "%md4(' foo')") match false -xlat_purify ("foo bar" == "%{md4: foo}") +xlat_purify ("foo bar" == "%md4(' foo')") match false xlat_purify ("foo" == "bar") @@ -334,11 +334,11 @@ match false xlat_purify (&User-Name == "bob") match (&User-Name == "bob") -xlat_purify (&User-Name == %{md4: blah}) +xlat_purify (&User-Name == %md4(' blah')) match (&User-Name == 0x544924d05ec4481925ba3749a096a0a7) # and without the double quotes. -xlat_purify (&User-Name == %{md4: blah}) +xlat_purify (&User-Name == %md4(' blah')) match (&User-Name == 0x544924d05ec4481925ba3749a096a0a7) xlat_purify (ipaddr)127.0.0.1 == 2130706433 @@ -429,8 +429,8 @@ match ("foo" == &User-Name) # # ERROR: Failed casting 0x002ade8665c69219ca16bd108d92c8d5 to data type uint32: Invalid cast from octets to uint32. Source length 16 is greater than destination type size 4 # -xlat_purify (integer)"%{md4: 1 + 1}" < &NAS-Port -match (%(cast:uint32 "%{md4: 1 + 1}") < &NAS-Port) +xlat_purify (integer)"%md4(' 1 + 1')" < &NAS-Port +match (%cast(uint32, "%md4(' 1 + 1')") < &NAS-Port) # # The string gets parsed as an IP address. @@ -463,7 +463,7 @@ match ((ipaddr)&PMIP6-Home-IPv4-HoA == &Framed-IP-Address) # but these are allowed xlat_purify (ether)&Tmp-uint64-0 == "%interpreter('foo')" -match ((ether)&Tmp-uint64-0 == %(cast:string "%(interpreter:'foo')")) +match ((ether)&Tmp-uint64-0 == %cast(string, "%interpreter('foo')")) xlat_purify (ipaddr)&Filter-Id == &Framed-IP-Address match ((ipaddr)&Filter-Id == &Framed-IP-Address) @@ -492,7 +492,7 @@ match (&User-Name[n] == "bob") #match &Foo-Bar xlat_purify &Acct-Input-Octets > "%{Session-Timeout}" -match (&Acct-Input-Octets > %(cast:string "%{Session-Timeout}")) +match (&Acct-Input-Octets > %cast(string, "%{Session-Timeout}")) xlat_purify &Acct-Input-Octets > &Session-Timeout match (&Acct-Input-Octets > &Session-Timeout) @@ -716,16 +716,16 @@ match ((&User-Name == "bob") && ((&User-Password == "bob") || &EAP-Message)) # rcode tests # xlat_purify handled && (&User-Name == "bob") -match (%{rcode:'handled'} && (&User-Name == "bob")) +match (%rcode('handled') && (&User-Name == "bob")) xlat_purify (&User-Name == "bob") && (&User-Password == "bob") && handled -match ((&User-Name == "bob") && (&User-Password == "bob") && %{rcode:'handled'}) +match ((&User-Name == "bob") && (&User-Password == "bob") && %rcode('handled')) xlat_purify handledx match ERROR offset 1: Unexpected text - attribute names must prefixed with '&' xlat_purify handled -match %{rcode:'handled'} +match %rcode('handled') # # Automatic casting diff --git a/src/tests/unit/xlat/expr.txt b/src/tests/unit/xlat/expr.txt index 12c04b1ab36..1f18212a4a8 100644 --- a/src/tests/unit/xlat/expr.txt +++ b/src/tests/unit/xlat/expr.txt @@ -93,8 +93,8 @@ match ((1 < 2) || (4 > 3) || (4 == 4) || (1 < 2)) xlat_expr &Filter-Id match &Filter-Id -xlat_expr %{md5:foo} + "foo" -match (%{md5:foo} + "foo") +xlat_expr %md5('foo') + "foo" +match (%md5('foo') + "foo") # We can name the xlat's, tho we don't need to xlat_expr %(op_add:4 3) + 6 @@ -111,7 +111,7 @@ xlat_expr 1 < 2 < 3 match ((1 < 2) < 3) xlat_expr (uint32) %(concat:1 2) -match %(cast:uint32 %(concat:1 2)) +match %cast(uint32, %concat(1, 2)) # # Mashing multiple brackets together. The brackets are removed as @@ -136,10 +136,10 @@ xlat_expr 5 + 5 - 10 match ((5 + 5) - 10) xlat_expr (integer) &Service-Type -match %(cast:uint32 &Service-Type) +match %cast(uint32, &Service-Type) xlat_expr (uint32) (&Service-Type) -match %(cast:uint32 &Service-Type) +match %cast(uint32, &Service-Type) count match 69 diff --git a/src/tests/unit/xlat/func.txt b/src/tests/unit/xlat/func.txt index ece707192c6..ef7d614ef52 100644 --- a/src/tests/unit/xlat/func.txt +++ b/src/tests/unit/xlat/func.txt @@ -12,7 +12,7 @@ xlat %Y() match %Y xlat %explode("a,b,c,d", ',') -match %(explode:"a,b,c,d" ',') +match %explode("a,b,c,d", ',') #xlat %md5(foo) #match foo diff --git a/src/tests/unit/xlat/purify.txt b/src/tests/unit/xlat/purify.txt index df5f6585ea5..d0c73925afe 100644 --- a/src/tests/unit/xlat/purify.txt +++ b/src/tests/unit/xlat/purify.txt @@ -112,7 +112,7 @@ match 2 xlat_purify &Filter-Id match &Filter-Id -xlat_purify %{md5:foo} + "bar" +xlat_purify %md5('foo') + "bar" match 0xacbd18db4cc2f85cedef654fccc4a4d8626172 # We can name the xlat's, tho we don't need to @@ -188,7 +188,7 @@ xlat_purify ~fail match ERROR offset 6: Invalid operation on module return code xlat_purify !fail -match !%{rcode:'fail'} +match !%rcode('fail') # # Casts and such @@ -196,13 +196,13 @@ match !%{rcode:'fail'} # @todo - xlat_tokenize() does not call purify # xlat_purify (string)(%{1 + 2}) -match %(cast:string (1 + 2)) +match %cast(string, (1 + 2)) # # This is a different code path than the above. # xlat_purify (string)%{1 + 2} -match %(cast:string (1 + 2)) +match %cast(string, (1 + 2)) xlat_purify "hello" match "hello" @@ -221,14 +221,14 @@ match "hello 3 bob" # The real run-time tests work # xlat_purify "hello %{1 + 2} bob" -match %(cast:string "hello (1 + 2) bob") +match %cast(string, "hello (1 + 2) bob") # # New syntax! # migrate xlat_new_functions = yes -xlat_purify %{md5:foo} +xlat_purify %md5('foo') match 0xacbd18db4cc2f85cedef654fccc4a4d8 xlat_purify %explode("a,b,c,d", ',') @@ -250,7 +250,7 @@ match 0x5e153571422b69cf5c5f7ce5f03985b5 # This is a reference to the contents of &User-Name # xlat_purify %md5(&User-Name) -match %{md5:&User-Name} +match %md5(&User-Name) xlat_purify %md5('foo')