Expressions improvements

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

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
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

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

Patch attached, comments welcome...


httpd-2.4.x-expr-v2.patch (65K) Download Attachment
Reply | Threaded
Open this post in threaded view

Re: Expressions improvements

Yann Ylavic
On Fri, Jul 14, 2017 at 11:57 PM, Yann Ylavic <[hidden email]> wrote:
> Patch attached, comments welcome...

Assuming lazy consensus :)

I'll start to rebase the patch on trunk and commit it, hopefully more
reviewers then.

> Regards,
> Yann.