httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Covener <cove...@gmail.com>
Subject Re: svn commit: r1642154 - in /httpd/httpd/trunk: docs/manual/expr.xml include/ap_expr.h server/util_expr_eval.c server/util_expr_parse.y
Date Fri, 05 Dec 2014 16:09:48 GMT
On Fri, Dec 5, 2014 at 11:01 AM, Jan Kalu┼ża <jkaluza@redhat.com> wrote:
> On 12/05/2014 02:26 PM, Eric Covener wrote:
>>
>> On Thu, Nov 27, 2014 at 8:46 AM,  <jkaluza@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.

Mime
View raw message