Skip to content

Commit e1316f8

Browse files
author
Stefan Fritsch
committed
Fix SetEnvIfExpr to work with expressions that do not set the regexp
reference data. Add some trace logging. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1039876 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9022059 commit e1316f8

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

modules/metadata/mod_setenvif.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,16 +637,19 @@ static int match_headers(request_rec *r)
637637
val_len = val ? strlen(val) : 0;
638638
}
639639

640-
/*
641-
* A NULL value indicates that the header field or special entity
642-
* wasn't present or is undefined. Represent that as an empty string
643-
* so that REs like "^$" will work and allow envariable setting
644-
* based on missing or empty field.
645-
*/
646-
if (val == NULL) {
647-
val = "";
648-
val_len = 0;
649-
}
640+
}
641+
642+
/*
643+
* A NULL value indicates that the header field or special entity
644+
* wasn't present or is undefined. Represent that as an empty string
645+
* so that REs like "^$" will work and allow envariable setting
646+
* based on missing or empty field. This is also necessary to make
647+
* ap_pregsub work after evaluating an ap_expr which does set the
648+
* regexp backref data.
649+
*/
650+
if (val == NULL) {
651+
val = "";
652+
val_len = 0;
650653
}
651654

652655
if ((b->pattern && apr_strmatch(b->pattern, val, val_len)) ||
@@ -675,6 +678,12 @@ static int match_headers(request_rec *r)
675678
}
676679
}
677680
}
681+
if (APLOGrtrace2(r)) {
682+
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
683+
"Setting envvar(s): %s",
684+
apr_array_pstrcat(r->pool, arr, ' '));
685+
686+
}
678687
}
679688
}
680689

0 commit comments

Comments
 (0)