| 476 | } |
| 477 | |
| 478 | static char *try_redirect(request_rec *r, int *status) |
| 479 | { |
| 480 | alias_dir_conf *dirconf = |
| 481 | (alias_dir_conf *) ap_get_module_config(r->per_dir_config, &alias_module); |
| 482 | |
| 483 | if (dirconf->redirect_set) { |
| 484 | apr_uri_t uri; |
| 485 | const char *err = NULL; |
| 486 | char *found = ""; |
| 487 | |
| 488 | if (dirconf->redirect) { |
| 489 | |
| 490 | found = apr_pstrdup(r->pool, |
| 491 | ap_expr_str_exec(r, dirconf->redirect, &err)); |
| 492 | if (err) { |
| 493 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02826) |
| 494 | "Can't evaluate redirect expression: %s", err); |
| 495 | return PREGSUB_ERROR; |
| 496 | } |
| 497 | |
| 498 | apr_uri_parse(r->pool, found, &uri); |
| 499 | /* Do not escape the query string or fragment. */ |
| 500 | found = apr_uri_unparse(r->pool, &uri, APR_URI_UNP_OMITQUERY); |
| 501 | found = ap_escape_uri(r->pool, found); |
| 502 | if (uri.query) { |
| 503 | found = apr_pstrcat(r->pool, found, "?", uri.query, NULL); |
| 504 | } |
| 505 | if (uri.fragment) { |
| 506 | found = apr_pstrcat(r->pool, found, "#", uri.fragment, NULL); |
| 507 | } |
| 508 | |
| 509 | } |
| 510 | |
| 511 | *status = dirconf->redirect_status; |
| 512 | return found; |
| 513 | |
| 514 | } |
| 515 | |
| 516 | return NULL; |
| 517 | } |
| 518 | |
| 519 | static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, |
| 520 | int is_redir, int *status) |
no test coverage detected