Skip to content

Commit cfb8882

Browse files
committed
use AP_EXPR_FLAG_RESTRICTED in htaccess
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1933349 13f79535-47bb-0310-9956-ffa450edef68
1 parent 76dac5d commit cfb8882

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
@@ -3686,12 +3686,17 @@ static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf,
36863686
newcond->regexp = regexp;
36873687
}
36883688
else if (newcond->ptype == CONDPAT_AP_EXPR) {
3689+
int in_htaccess = cmd->pool == cmd->temp_pool;
36893690
unsigned int flags = newcond->flags & CONDFLAG_NOVARY ?
36903691
AP_EXPR_FLAG_DONT_VARY : 0;
3692+
/* Use restricted ap_expr() parser in htaccess context. */
3693+
if (in_htaccess) flags |= AP_EXPR_FLAG_RESTRICTED;
36913694
newcond->expr = ap_expr_parse_cmd(cmd, a2, flags, &err, NULL);
36923695
if (err)
36933696
return apr_psprintf(cmd->pool, "RewriteCond: cannot compile "
3694-
"expression \"%s\": %s", a2, err);
3697+
"expression%s \"%s\" %s",
3698+
in_htaccess ? " in htaccess context" : "",
3699+
a2, err);
36953700
}
36963701

36973702
return NULL;

modules/metadata/mod_setenvif.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ static const char *add_setenvifexpr(cmd_parms *cmd, void *mconfig,
435435
sei_cfg_rec *sconf;
436436
sei_entry *new;
437437
const char *err;
438+
unsigned int flags = 0;
439+
440+
/* Use restricted ap_expr() parser in htaccess context. */
441+
if (cmd->pool == cmd->temp_pool) {
442+
flags |= AP_EXPR_FLAG_RESTRICTED;
443+
}
438444

439445
/*
440446
* Determine from our context into which record to put the entry.
@@ -458,7 +464,7 @@ static const char *add_setenvifexpr(cmd_parms *cmd, void *mconfig,
458464
new->regex = NULL;
459465
new->pattern = NULL;
460466
new->preg = NULL;
461-
new->expr = ap_expr_parse_cmd(cmd, expr, 0, &err, NULL);
467+
new->expr = ap_expr_parse_cmd(cmd, expr, flags, &err, NULL);
462468
if (err)
463469
return apr_psprintf(cmd->pool, "Could not parse expression \"%s\": %s",
464470
expr, err);

modules/proxy/mod_proxy_fcgi.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,15 @@ static const char *cmd_setenv(cmd_parms *cmd, void *in_dconf,
13421342
const char *err;
13431343
sei_entry *new;
13441344
const char *envvar = arg2;
1345+
unsigned int flags = 0;
1346+
1347+
/* Use restricted ap_expr() parser in htaccess context. */
1348+
if (cmd->pool == cmd->temp_pool) {
1349+
flags |= AP_EXPR_FLAG_RESTRICTED;
1350+
}
13451351

13461352
new = apr_array_push(dconf->env_fixups);
1347-
new->cond = ap_expr_parse_cmd(cmd, arg1, 0, &err, NULL);
1353+
new->cond = ap_expr_parse_cmd(cmd, arg1, flags, &err, NULL);
13481354
if (err) {
13491355
return apr_psprintf(cmd->pool, "Could not parse expression \"%s\": %s",
13501356
arg1, err);
@@ -1371,7 +1377,8 @@ static const char *cmd_setenv(cmd_parms *cmd, void *in_dconf,
13711377
arg3 = "";
13721378
}
13731379

1374-
new->subst = ap_expr_parse_cmd(cmd, arg3, AP_EXPR_FLAG_STRING_RESULT, &err, NULL);
1380+
flags |= AP_EXPR_FLAG_STRING_RESULT;
1381+
new->subst = ap_expr_parse_cmd(cmd, arg3, flags, &err, NULL);
13751382
if (err) {
13761383
return apr_psprintf(cmd->pool, "Could not parse expression \"%s\": %s",
13771384
arg3, err);

0 commit comments

Comments
 (0)