From: Alan T. DeKok Date: Tue, 26 Mar 2024 15:29:47 +0000 (-0400) Subject: ':' is no longer special in xlats X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cf33e57dbc1b99caf3c8ae23ca41e18c97cbea5;p=thirdparty%2Ffreeradius-server.git ':' is no longer special in xlats --- diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 202e8acfb8c..a9d52aa29e5 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -492,7 +492,7 @@ static int xlat_tokenize_attribute(xlat_exp_head_t *head, fr_sbuff_t *in, MEM(node = xlat_exp_alloc_null(head)); if (tmpl_afrom_attr_substr(node, &err, &vpt, in, p_rules, &our_t_rules) < 0) { /* - * If the parse error occurred before the ':' + * If the parse error occurred before a terminator, * then the error is changed to 'Unknown module', * as it was more likely to be a bad module name, * than a request qualifier. @@ -569,7 +569,6 @@ int xlat_tokenize_expansion(xlat_exp_head_t *head, fr_sbuff_t *in, char hint; fr_sbuff_term_t hint_tokens = FR_SBUFF_TERMS( L(" "), /* First special token is a ' ' - Likely a syntax error */ - L(":"), /* First special token is a ':' i.e. '%{func:' */ L("["), /* First special token is a '[' i.e. '%{attr[]}' */ L("}") /* First special token is a '}' i.e. '%{}' */ ); @@ -601,20 +600,10 @@ int xlat_tokenize_expansion(xlat_exp_head_t *head, fr_sbuff_t *in, #endif /* HAVE_REGEX */ - /* - * See if it's an old-style function name. - */ - fr_sbuff_marker(&s_m, in); - len = fr_sbuff_adv_past_allowed(in, SIZE_MAX, xlat_func_chars, NULL); - if (fr_sbuff_is_char(in, ':')) { - if (!len) goto missing_function; - goto check_for_attr; - } - /* * See if it's an attribute reference, with possible array stuff. */ - len += fr_sbuff_adv_past_allowed(in, SIZE_MAX, tmpl_attr_allowed_chars, NULL); + len = fr_sbuff_adv_past_allowed(in, SIZE_MAX, tmpl_attr_allowed_chars, NULL); if (fr_sbuff_is_char(in, '}')) { if (!len) goto empty_disallowed; goto check_for_attr; @@ -715,11 +704,6 @@ check_for_attr: fr_strerror_const("Empty expression is invalid"); return -1; - case ':': - missing_function: - fr_strerror_const("Missing expansion function"); - return -1; - case '[': fr_strerror_const("Missing attribute name"); return -1; diff --git a/src/tests/unit/xlat/base.txt b/src/tests/unit/xlat/base.txt index 2255a0b38d7..95a4cdba138 100644 --- a/src/tests/unit/xlat/base.txt +++ b/src/tests/unit/xlat/base.txt @@ -158,10 +158,10 @@ xlat %{} match ERROR offset 3: Empty expression is invalid xlat %{:} -match ERROR offset 3: Missing expansion function +match ERROR offset 3: No operand found. Expected &ref, literal, 'quoted literal', "%{expansion}", or enum value xlat %{:bar} -match ERROR offset 3: Missing expansion function +match ERROR offset 3: No operand found. Expected &ref, literal, 'quoted literal', "%{expansion}", or enum value xlat %foo(' bar') match ERROR offset 2: Unresolved expansion functions are not allowed here