Skip to content

Commit 05e6c50

Browse files
committed
Merge r1933349 from trunk:
use AP_EXPR_FLAG_RESTRICTED in htaccess git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1933350 13f79535-47bb-0310-9956-ffa450edef68
1 parent d04119e commit 05e6c50

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

modules/mappers/mod_rewrite.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3679,12 +3679,17 @@ static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf,
36793679
newcond->regexp = regexp;
36803680
}
36813681
else if (newcond->ptype == CONDPAT_AP_EXPR) {
3682+
int in_htaccess = cmd->pool == cmd->temp_pool;
36823683
unsigned int flags = newcond->flags & CONDFLAG_NOVARY ?
36833684
AP_EXPR_FLAG_DONT_VARY : 0;
3685+
/* Use restricted ap_expr() parser in htaccess context. */
3686+
if (in_htaccess) flags |= AP_EXPR_FLAG_RESTRICTED;
36843687
newcond->expr = ap_expr_parse_cmd(cmd, a2, flags, &err, NULL);
36853688
if (err)
36863689
return apr_psprintf(cmd->pool, "RewriteCond: cannot compile "
3687-
"expression \"%s\": %s", a2, err);
3690+
"expression%s \"%s\" %s",
3691+
in_htaccess ? " in htaccess context" : "",
3692+
a2, err);
36883693
}
36893694

36903695
return NULL;

modules/metadata/mod_setenvif.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ static const char *add_setenvifexpr(cmd_parms *cmd, void *mconfig,
422422
sei_cfg_rec *sconf;
423423
sei_entry *new;
424424
const char *err;
425+
unsigned int flags = 0;
426+
427+
/* Use restricted ap_expr() parser in htaccess context. */
428+
if (cmd->pool == cmd->temp_pool) {
429+
flags |= AP_EXPR_FLAG_RESTRICTED;
430+
}
425431

426432
/*
427433
* Determine from our context into which record to put the entry.
@@ -445,7 +451,7 @@ static const char *add_setenvifexpr(cmd_parms *cmd, void *mconfig,
445451
new->regex = NULL;
446452
new->pattern = NULL;
447453
new->preg = NULL;
448-
new->expr = ap_expr_parse_cmd(cmd, expr, 0, &err, NULL);
454+
new->expr = ap_expr_parse_cmd(cmd, expr, flags, &err, NULL);
449455
if (err)
450456
return apr_psprintf(cmd->pool, "Could not parse expression \"%s\": %s",
451457
expr, err);

modules/proxy/mod_proxy_fcgi.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,15 @@ static const char *cmd_setenv(cmd_parms *cmd, void *in_dconf,
13381338
const char *err;
13391339
sei_entry *new;
13401340
const char *envvar = arg2;
1341+
unsigned int flags = 0;
1342+
1343+
/* Use restricted ap_expr() parser in htaccess context. */
1344+
if (cmd->pool == cmd->temp_pool) {
1345+
flags |= AP_EXPR_FLAG_RESTRICTED;
1346+
}
13411347

13421348
new = apr_array_push(dconf->env_fixups);
1343-
new->cond = ap_expr_parse_cmd(cmd, arg1, 0, &err, NULL);
1349+
new->cond = ap_expr_parse_cmd(cmd, arg1, flags, &err, NULL);
13441350
if (err) {
13451351
return apr_psprintf(cmd->pool, "Could not parse expression \"%s\": %s",
13461352
arg1, err);
@@ -1367,7 +1373,8 @@ static const char *cmd_setenv(cmd_parms *cmd, void *in_dconf,
13671373
arg3 = "";
13681374
}
13691375

1370-
new->subst = ap_expr_parse_cmd(cmd, arg3, AP_EXPR_FLAG_STRING_RESULT, &err, NULL);
1376+
flags |= AP_EXPR_FLAG_STRING_RESULT;
1377+
new->subst = ap_expr_parse_cmd(cmd, arg3, flags, &err, NULL);
13711378
if (err) {
13721379
return apr_psprintf(cmd->pool, "Could not parse expression \"%s\": %s",
13731380
arg3, err);

0 commit comments

Comments
 (0)