From: Alan T. DeKok Date: Sun, 11 Dec 2022 14:47:26 +0000 (-0500) Subject: allow (...) in xlat arguments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1992612cdb413a0155a1e248f3fffd6ec3d7200f;p=thirdparty%2Ffreeradius-server.git allow (...) in xlat arguments --- diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 1f9af75ba6e..0ad07896540 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -5235,6 +5235,15 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t i continue; } + /* + * Allow (...) and {...} + */ + if ((*p == '{') || (*p == '(')) { + p++; + depth++; + continue; + } + p++; } diff --git a/src/tests/keywords/expr-condition b/src/tests/keywords/expr-condition new file mode 100644 index 00000000000..c57beb11e6a --- /dev/null +++ b/src/tests/keywords/expr-condition @@ -0,0 +1,17 @@ +# +# @todo - update the configuration file parse to allow this. +# +# +# @todo - allow just a bare +# +# &NAS-Port := 5 + (&User-Name == "bob") +# +# which means updating the config file parser, too. +# +&NAS-Port := %{expr:5 + (&User-Name == "bob")} + +if !(&NAS-Port == 6) { + test_fail +} + +success