36#if APR_VERSION_AT_LEAST(1,5,0)
43#undef APLOG_MODULE_INDEX
44#define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
53#define LOG_MARK(info) __FILE__, __LINE__, (info)->module_index
75#define AP_EXPR_MAX_RECURSION 20
82 *
ctx->err =
"Recursion limit reached";
175 *
ctx->err =
"Internal evaluation error: Unknown word expression node";
197 if (!
ctx->re_pmatch || !
ctx->re_source || !*
ctx->re_source
198 || **
ctx->re_source ==
'\0' ||
ctx->re_nmatch <
n + 1)
201 len =
ctx->re_pmatch[
n].rm_eo -
ctx->re_pmatch[
n].rm_so;
302 if (
regex->re_nsub > 0) {
317 *
ctx->err =
"Internal evaluation error: Unknown comp expression node";
337 for (
i = 0;
i <
n1;
i++) {
389 ctx.inputlen = strlen(expr);
390 ctx.inputptr =
ctx.inputbuf;
396 ctx.scan_buf[0] =
'\0';
397 ctx.scan_ptr =
ctx.scan_buf;
411 else if (
ctx.error2) {
416 return "syntax error";
436 info->filename =
cmd->directive->filename;
437 info->line_number =
cmd->directive->line_num;
439 info->module_index = module_index;
538#define MARK APLOG_MARK,loglevel,0,s
539#define DUMP_E_E(op, e1, e2) \
540 do { ap_log_error(MARK,"%*s%s: %pp %pp", indent, " ", op, e1, e2); \
541 if (e1) expr_dump_tree(e1, s, loglevel, indent + 2); \
542 if (e2) expr_dump_tree(e2, s, loglevel, indent + 2); \
544#define DUMP_S_E(op, s1, e1) \
545 do { ap_log_error(MARK,"%*s%s: '%s' %pp", indent, " ", op, (char *)s1, e1); \
546 if (e1) expr_dump_tree(e1, s, loglevel, indent + 2); \
548#define DUMP_S_P(op, s1, p1) \
549 ap_log_error(MARK,"%*s%s: '%s' %pp", indent, " ", op, (char *)s1, p1);
550#define DUMP_P_P(op, p1, p2) \
551 ap_log_error(MARK,"%*s%s: %pp %pp", indent, " ", op, p1, p2);
552#define DUMP_S_S(op, s1, s2) \
553 ap_log_error(MARK,"%*s%s: '%s' '%s'", indent, " ", op, (char *)s1, (char *)s2)
554#define DUMP_P(op, p1) \
555 ap_log_error(MARK,"%*s%s: %pp", indent, " ", op, p1);
556#define DUMP_IP(op, p1) \
557 ap_log_error(MARK,"%*s%s: %d", indent, " ", op, *(int *)p1);
558#define DUMP_S(op, s1) \
559 ap_log_error(MARK,"%*s%s: '%s'", indent, " ", op, (char *)s1)
561#define CASE_OP(op) case op: name = #op ; break;
566 switch (
e->node_op) {
573 switch (
e->node_op) {
590 switch (
e->node_op) {
627 switch (
e->node_op) {
662 switch (
e->node_op) {
679 switch (
e->node_op) {
693 DUMP_P(
"op_Regex",
e->node_arg1);
697 DUMP_IP(
"op_RegexBackref",
e->node_arg1);
804 *
ctx->err =
"Internal evaluation error: Unknown expression node";
832 if (
ctx->re_pmatch) {
843 "Evaluation of expression from %s:%d failed: %s",
844 ctx->info->filename,
ctx->info->line_number, *
ctx->err);
848 "Evaluation of string expression from %s:%d gave: %s",
849 ctx->info->filename,
ctx->info->line_number,
850 *
ctx->result_string);
858 "Evaluation of expression from %s:%d failed: %s",
859 ctx->info->filename,
ctx->info->line_number, *
ctx->err);
864 "Evaluation of expression from %s:%d gave: %d",
865 ctx->info->filename,
ctx->info->line_number,
rc);
867 if (
ctx->vary_this && *
ctx->vary_this)
925 return (
const char *)
info->root_node->node_arg1;
976 if (*
ctx->vary_this) {
988 const char *
name = (
const char *)
data;
993 if (
name[2] ==
's') {
999 t =
ctx->r->err_headers_out;
1001 else if (
name[0] ==
'n')
1003 else if (
name[3] ==
'e')
1004 t =
ctx->r->subprocess_env;
1005 else if (
name[3] ==
'_')
1006 t =
ctx->r->headers_in;
1008 t =
ctx->r->headers_in;
1097#if APR_VERSION_AT_LEAST(1,6,0)
1105#define MAX_FILE_SIZE 10*1024*1024
1133 *
ctx->err =
"Cannot allocate memory";
1169 "%s %% escape in unescape('%s') at %s:%d",
1171 ctx->info->filename,
ctx->info->line_number);
1177 const char *
name = (
const char *)
data;
1179 return (
arg[0] ==
'\0');
1181 return (
arg[0] !=
'\0');
1187 const char *
name = (
const char *)
data;
1238 if (
rsub->status < 400) {
1242 "Subrequest for -U %s at %s:%d gave status: %d",
1257 if (
rsub->status < 300 &&
1263 "Subrequest for -F %s at %s:%d gave status: %d",
1312 return c->client_ip;
1351 "CONTEXT_DOCUMENT_ROOT",
1395 return (
r->
main !=
NULL ?
"true" :
"false");
1454 "HTTP_PROXY_CONNECTION",
1554 "-%s requires subnet/netmask as constant argument",
1567 *
parms->err =
"parsing of subnet/netmask failed";
1624 const char *
arg1,
const char *
arg2)
1630 const char *
arg1,
const char *
arg2)
1636 const char *
arg1,
const char *
arg2)
1681#if APR_VERSION_AT_LEAST(1,6,0)
1715 switch (
parms->type) {
1718 while (
prov->func) {
1736 switch (
parms->type) {
1757 &&
prov->restricted) {
1760 "%s%s not available in restricted context",
1766 if (
prov->arg_parsing_func) {
1789 switch (
parms->type) {
1797 type =
"List-returning function";
1800 type =
"Unary operator";
1803 type =
"Binary operator";
1806 *
parms->err =
"Invalid expression type in expr_lookup";
#define AP_DECLARE_NONSTD(type)
#define AP_EXPR_FUNC_LIST
#define AP_EXPR_FUNC_OP_BINARY
#define AP_EXPR_FUNC_STRING
#define AP_EXPR_FUNC_OP_UNARY
#define AP_IMPLEMENT_HOOK_RUN_FIRST(ret, name, args_decl, args_use, decline)
int int const char ** match
const char apr_size_t ap_regmatch_t * pmatch
const char apr_size_t len
const char apr_size_t nmatch
APR-UTIL Base64 Encoding.
APR general purpose library routines.
#define APR_SHA1_DIGESTSIZE
APR Versioning Interface.
static apr_pool_t * pconf
void ap_hook_post_config(ap_HOOK_post_config_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
#define ap_http_scheme(r)
const char * ap_get_server_banner(void)
apr_port_t ap_get_server_port(const request_rec *r)
const char * ap_document_root(request_rec *r)
const char * ap_get_remote_logname(request_rec *r)
const char * ap_get_server_name_for_url(request_rec *r)
const unsigned char * buf
#define MODULE_MAGIC_NUMBER_MAJOR
int ap_ssl_conn_is_ssl(conn_rec *c)
request_rec * ap_sub_req_lookup_uri(const char *new_uri, const request_rec *r, ap_filter_t *next_filter)
request_rec * ap_sub_req_lookup_file(const char *new_file, const request_rec *r, ap_filter_t *next_filter)
void ap_destroy_sub_req(request_rec *r)
apr_brigade_flush void * ctx
apr_pool_t apr_dbd_t apr_dbd_results_t ** res
const char apr_ssize_t int flags
#define APR_ESCAPE_LDAP_ALL
#define APR_ESCAPE_STRING
#define APR_HOOK_LINK(name)
#define APR_HOOK_STRUCT(members)
#define APR_HOOK_REALLY_LAST
#define APR_RETRIEVE_OPTIONAL_FN(name)
#define APR_OPTIONAL_FN_TYPE(name)
#define APR_DECLARE_OPTIONAL_FN(ret, name, args)
const char *() ap_expr_string_func_t(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
int ap_expr_lookup_default(ap_expr_lookup_parms *parms)
#define AP_EXPR_FLAG_DONT_VARY
#define AP_EXPR_FLAG_STRING_RESULT
apr_array_header_t *() ap_expr_list_func_t(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
int ap_expr_exec(request_rec *r, const ap_expr_info_t *info, const char **err)
ap_expr_info_t * ap_expr_parse_cmd_mi(const cmd_parms *cmd, const char *expr, unsigned int flags, const char **err, ap_expr_lookup_fn_t *lookup_fn, int module_index)
int() ap_expr_lookup_fn_t(ap_expr_lookup_parms *parms)
int ap_expr_exec_re(request_rec *r, const ap_expr_info_t *info, apr_size_t nmatch, ap_regmatch_t *pmatch, const char **source, const char **err)
#define AP_EXPR_FLAG_SSL_EXPR_COMPAT
int ap_expr_op_unary_t(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
const char * ap_expr_parse(apr_pool_t *pool, apr_pool_t *ptemp, ap_expr_info_t *info, const char *expr, ap_expr_lookup_fn_t *lookup_fn)
void ap_hook_expr_lookup(ap_HOOK_expr_lookup_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
const char * ap_expr_str_exec(request_rec *r, const ap_expr_info_t *info, const char **err)
int ap_run_expr_lookup(ap_expr_lookup_parms *parms)
#define AP_EXPR_FLAG_RESTRICTED
int ap_expr_op_binary_t(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1, const char *arg2)
const char * ap_expr_str_exec_re(request_rec *r, const ap_expr_info_t *info, apr_size_t nmatch, ap_regmatch_t *pmatch, const char **source, const char **err)
int ap_expr_exec_ctx(ap_expr_eval_ctx_t *ctx)
const char *() ap_expr_var_func_t(ap_expr_eval_ctx_t *ctx, const void *data)
void ap_expr_init(apr_pool_t *p)
int ap_cstr_casecmp(const char *s1, const char *s2)
char * ap_pbase64encode(apr_pool_t *p, char *string)
#define ap_escape_uri(ppool, path)
void ap_bin2hex(const void *src, apr_size_t srclen, char *dest)
#define ap_strchr_c(s, c)
const char * ap_context_prefix(request_rec *r)
const char * ap_context_document_root(request_rec *r)
void ap_str_toupper(char *s)
#define AP_DEBUG_ASSERT(exp)
char * ap_pbase64decode(apr_pool_t *p, const char *bufcoded)
void ap_str_tolower(char *s)
int ap_array_str_contains(const apr_array_header_t *array, const char *s)
int ap_unescape_url_keep2f(char *url, int decode_slashes)
const char int apr_pool_t * pool
apr_seek_where_t apr_off_t * offset
apr_array_header_t ** result
#define APR_FNM_CASE_BLIND
int strcasecmp(const char *a, const char *b)
apr_vformatter_buff_t * c
apr_sockaddr_t apr_sockaddr_t apr_sockaddr_t * source
apr_interval_time_t apr_pollcb_cb_t func
#define apr_pcalloc(p, size)
apr_int32_t apr_int32_t apr_int32_t err
const char const char *const * args
apr_size_t apr_size_t const char apr_time_exp_t * tm
const char * ap_get_useragent_host(request_rec *req, int type, int *str_is_ip)
static int http2_is_h2(conn_rec *)
ap_expr_node_op_e node_op
Structure to store things which are per connection.
const char *const * names
ap_expr_lookup_fn_t * arg_parsing_func
A structure that represents the current request.
const char * content_type
apr_table_t * subprocess_env
A structure to store information for each virtual server.
static apr_array_header_t * a1
static const char * filesize_func(ap_expr_eval_ctx_t *ctx, const void *data, char *arg)
static const char * env_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char * ap_expr_eval_word(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
static int strcmplex(const char *str1, const char *str2)
static int op_fnmatch(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1, const char *arg2)
static int op_file_min(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char * conn_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
static const char * ap_expr_eval_string_func(ap_expr_eval_ctx_t *ctx, const ap_expr_t *info, const ap_expr_t *args)
ap_expr_t * ap_expr_make(ap_expr_node_op_e op, const void *a1, const void *a2, ap_expr_parse_ctx_t *ctx)
static int op_strmatch(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1, const char *arg2)
static const char *const req_header_var_names[]
static int inc_rec(ap_expr_eval_ctx_t *ctx)
static const char * unescape_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static int ap_expr_eval_binary_op(ap_expr_eval_ctx_t *ctx, const ap_expr_t *info, const ap_expr_t *args)
static int op_ipmatch(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1, const char *arg2)
static int op_nz(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static int core_expr_lookup(ap_expr_lookup_parms *parms)
static const char * toupper_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char * ap_expr_eval_var(ap_expr_eval_ctx_t *ctx, ap_expr_var_func_t *func, const void *data)
static ap_expr_t * ap_expr_info_make(int type, const char *name, ap_expr_parse_ctx_t *ctx, const ap_expr_t *arg)
static void add_vary(ap_expr_eval_ctx_t *ctx, const char *name)
static const char *const misc_var_names[]
static int op_file_link(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static int subnet_parse_arg(ap_expr_lookup_parms *parms)
static int ap_expr_eval_unary_op(ap_expr_eval_ctx_t *ctx, const ap_expr_t *info, const ap_expr_t *arg)
ap_expr_t * ap_expr_list_func_make(const char *name, const ap_expr_t *arg, ap_expr_parse_ctx_t *ctx)
static const char * md5_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
ap_expr_t * ap_expr_str_func_make(const char *name, const ap_expr_t *arg, ap_expr_parse_ctx_t *ctx)
static const struct expr_provider_single binary_op_providers[]
static const char * file_func(ap_expr_eval_ctx_t *ctx, const void *data, char *arg)
static const char * request_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
static const struct expr_provider_single unary_op_providers[]
static const char * escape_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char *const request_var_names[]
static const char * sha1_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static int ssl_expr_eval_comp(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
static int ap_expr_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
static const struct expr_provider_multi var_providers[]
ap_expr_t * ap_expr_binary_op_make(const char *name, const ap_expr_t *arg1, const ap_expr_t *arg2, ap_expr_parse_ctx_t *ctx)
static const char * base64_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const struct expr_provider_single string_func_providers[]
static int op_url_subr(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
ap_expr_t * ap_expr_var_make(const char *name, ap_expr_parse_ctx_t *ctx)
static int op_T(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static int op_file_xbit(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char * ap_expr_eval_re_backref(ap_expr_eval_ctx_t *ctx, unsigned int n)
static const char * misc_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
static int op_R(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1)
static const char * req_header_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
static int ap_expr_eval_comp(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
static const char * unbase64_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char * req_table_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static int expr_lookup_not_found(ap_expr_lookup_parms *parms)
static const char *const conn_var_names[]
static const char *const req_header_header_names[]
static int op_strcmatch(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1, const char *arg2)
static const char * osenv_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char * tolower_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static const char * ldap_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static int ap_expr_eval(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
#define AP_EXPR_MAX_RECURSION
ap_expr_t * ap_expr_unary_op_make(const char *name, const ap_expr_t *arg, ap_expr_parse_ctx_t *ctx)
static int op_file_subr(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
static apr_OFN_http2_is_h2_t * is_http2
static int intstrcmp(const char *s1, const char *s2)
void ap_expr_yyset_extra(ap_expr_parse_ctx_t *context, void *scanner)
int ap_expr_yylex_destroy(void *scanner)
int ap_expr_yylex_init(void **scanner)
char * ap_md5(apr_pool_t *p, const unsigned char *string)