On 12/05/2014 05:09 PM, Eric Covener wrote:
On Fri, Dec 5, 2014 at 11:01 AM, Jan Kaluža <jkal...@redhat.com> wrote:
On 12/05/2014 02:26 PM, Eric Covener wrote:

On Thu, Nov 27, 2014 at 8:46 AM,  <jkal...@apache.org> wrote:

* ap_exr: Add replace(string, from, to) function.


Is it possible to evaluate this from ap_expr_str_exec()?


Hm, it worked for me like this:

Require expr replace(%{REQUEST_METHOD},  "E", "O") == "GOT"

I think this uses ap_expr_exec / aka boolean result:

static authz_status expr_check_authorization(request_rec *r,
                                              const char *require_line,
                                              const void *parsed_require_line)
{
     const char *err = NULL;
     const struct require_expr_info *info = parsed_require_line;
     int rc = ap_expr_exec(r, info->expr, &err);

     if (rc < 0) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02320)
                       "Error evaluating expression in 'Require expr': %s",
                       err);
         return AUTHZ_GENERAL_ERROR;
     }
     else if (rc == 0) {
         if (info->want_user)
             return AUTHZ_DENIED_NO_USER;
         else
             return AUTHZ_DENIED;
     }
     else {
         return AUTHZ_GRANTED;
     }
}


This internally uses ap_expr_str_exec().

I am stuck on trying to get it to work. I think we cannot get to
multi-valued
functions from  the %{func:arg} syntax used when starting at string.


I think I'm lost here. Checking for ap_expr documentation, I don't see this
syntax. Can you describe this more. I'm sorry, but was checking ap_expr for
first time while doing this patch, so there might be things I overlooked.

I think it is the first function of its kind so it may not be easy.

When you actually want a string as the net result of an expression,
you start at "string" in ap_expr doc.

string      ::= stringpart
               | string stringpart

stringpart  ::= cstring
               | variable
               | rebackref

variable    ::= "%{" varname "}"
               | "%{" funcname ":" funcargs "}"

Full disclosure -- I don't understand this stuff so well, but I have
been learning on the job trying to make a dent in documenting some
different flavors of expressions in at least <if> and header set Foo
expr= so there is a starting point.

I see what you mean now, thanks. I will need some time to actually think about possible solutions.

Right now, I'm curious why we can't add:

stringpart  ::= function

But there may be some problem with that I don't see right now. Well, I will try to play with it and let you know.

Jan Kaluza

Reply via email to