Expressions improvements

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Expressions improvements

Yann Ylavic
Starting from a feature request on users@ some time ago (see [1] if
you are interested by long threads...), I made changes in the
expressions parser.

Currently there are two types of expressions handled by httpd, string
and conditional expressions, usable in different contexts, with
different syntaxes.

While conditional expressions are quite powerful with the definition
of "word", regexps and even string expressions (what's between the
quotes), the string expressions are more limited (no "word" nor
regexps).
So the idea is to open string expressions to the "word" :)

String expressions can reference a variable with %{var}, a function
call with %{func:arg}, or a regexp back-reference with $n, but that
almost all.
I propose that they now can reference almost anything with the
%{:word:} syntax, including conditions which become "true" or "false"
in a string context.
But this is not only about evaluating conditions in strings, the
"word" also gives access to list functions and regexps that can work
on list and return a string (or a sub-list...), like split// or
join//.

For the initial users@ case, it allows things like:
  Header always set "X-SubjectAltName" \
   "expr=%{: join/PeerExtList('subjectAltName')/', '/ :}"
or:
  Header always set "X-Client-in-SubjectAltName" \
   "expr=%{: %{REMOTE_ADDR} -in \
             ( PeerExtList('subjectAltName') =~ \
               split/.*?IPAddress:([^,]+)/$1/ ) :}"

Patch attached, comments welcome...


Regards,
Yann.

httpd-2.4.x-expr-v2.patch (65K) Download Attachment
Loading...