instead of xlat_tokenize(), as expressions can have many things
in them, including math. whereas xlat_tokenize() generally just
tokenizes one string
/*
* Parse the input as a literal expansion
*/
- if (xlat_tokenize(rctx,
+ if (xlat_tokenize_expression(rctx,
&rctx->ex,
&FR_SBUFF_IN(arg->vb_strvalue, arg->vb_length),
&(fr_sbuff_parse_rules_t){
.runtime_el = unlang_interpret_event_list(request),
},
.at_runtime = true
- }, 0) < 0) {
+ }) < 0) {
RPEDEBUG("Failed parsing expansion");
error:
talloc_free(rctx);
--- /dev/null
+uint32 index
+string ref
+string foo
+
+Filter-Id := { "a", "b" }
+index := 1
+
+#
+# Dynamically create an attribute reference
+#
+ref = "Filter-Id[" + index + "]"
+
+#
+# Evaluate the attribute as an unlang expression.
+#
+foo = %eval(%{ref})
+
+if (foo != "b") {
+ test_fail
+}
+
+ref = "1 + 2"
+
+foo = %eval(%{ref})
+
+if (foo != 3) {
+ test_fail
+}
+
+success