MCPcopy Index your code
hub / github.com/apache/httpd / ap_proxy_interpolate

Function ap_proxy_interpolate

modules/proxy/proxy_util.c:2524–2560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2522}
2523
2524PROXY_DECLARE(const char *) ap_proxy_interpolate(request_rec *r,
2525 const char *str)
2526{
2527 /* Interpolate an env str in a configuration string
2528 * Syntax ${var} --> value_of(var)
2529 * Method: replace one var, and recurse on remainder of string
2530 * Nothing clever here, and crap like nested vars may do silly things
2531 * but we'll at least avoid sending the unwary into a loop
2532 */
2533 const char *start;
2534 const char *end;
2535 const char *var;
2536 const char *val;
2537 const char *firstpart;
2538
2539 start = ap_strstr_c(str, "${");
2540 if (start == NULL) {
2541 return str;
2542 }
2543 end = ap_strchr_c(start+2, '}');
2544 if (end == NULL) {
2545 return str;
2546 }
2547 /* OK, this is syntax we want to interpolate. Is there such a var ? */
2548 var = apr_pstrmemdup(r->pool, start+2, end-(start+2));
2549 val = apr_table_get(r->subprocess_env, var);
2550 firstpart = apr_pstrmemdup(r->pool, str, (start-str));
2551
2552 if (val == NULL) {
2553 return apr_pstrcat(r->pool, firstpart,
2554 ap_proxy_interpolate(r, end+1), NULL);
2555 }
2556 else {
2557 return apr_pstrcat(r->pool, firstpart, val,
2558 ap_proxy_interpolate(r, end+1), NULL);
2559 }
2560}
2561
2562static apr_array_header_t *proxy_vars(request_rec *r, apr_array_header_t *hdr)
2563{

Callers 2

ap_proxy_trans_matchFunction · 0.85
proxy_varsFunction · 0.85

Calls 2

ap_strstr_cFunction · 0.85
ap_strchr_cFunction · 0.85

Tested by

no test coverage detected