[master] questions about recent changes in xlat

Arran Cudbard-Bell a.cudbardb at freeradius.org
Sat Oct 24 19:02:39 CEST 2020



> On Oct 24, 2020, at 8:30 AM, Alan DeKok <aland at deployingradius.com> wrote:
> 
> On Oct 24, 2020, at 8:44 AM, Chaigneau, Nicolas via Freeradius-Devel <freeradius-devel at lists.freeradius.org> wrote:
>> A couple of recent changes I've noticed in FreeRADIUS xlat framework:
>> 
>> 1)
>> "%%" is no longer transformed to "%" (it remains %%).
>> Function xlat_eval_one_letter has a case for '%' but it seems it's not called anymore.
>> In function xlat_sync_eval which should call xlat_eval_one_letter, I see that node->type is 1 (XLAT_LITERAL) instead of 2 (XLAT_ONE_LETTER).
>> 
>> Is this change intended ?
> 
>  Yes.  We've updated the parser to be smarter.  It no longer need %%.  Which was always ugly.

The new escape sequence is \% which is far more intuitive.

>> According to the documentation it should work:
>> https://github.com/FreeRADIUS/freeradius-server/blob/master/doc/antora/modules/unlang/pages/xlat/character.adoc
> 
>  We'll update the documentation, and also the upgrade guide.
> 
>> 2)
>> Using a form of xlat functions with no parameter is no longer working.
>> For example: %{myxlat}
>> 
>> This used to work (not too long ago).
>> This is useful to me, although I can still get the same result with: %{myxlat:}
>> But this is a bit ugly though...
>> 
>> Do you think we could get this to work again without the colon ?

No.

>  Possibly.  We're trying to regularize all of the parsing, expansions, etc.  Which means that some changes creep in.
> 
>  The main issue with not using the ":" is that the syntax becomes ambiguous.  Is %{foo} an attribute reference, or an xlat function?  You can't tell.

Exactly.  The old xlat code didn't support multi-pass resolution of attributes or functions because it was impossible to tell what was an attribute and what was a function.

That's why ':' is no longer allowed as a list specifier for attribute references in xlats.

-Arran


More information about the Freeradius-Devel mailing list