| 517 | } |
| 518 | |
| 519 | static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, |
| 520 | int is_redir, int *status) |
| 521 | { |
| 522 | alias_entry *entries = (alias_entry *) aliases->elts; |
| 523 | ap_regmatch_t regm[AP_MAX_REG_MATCH]; |
| 524 | char *found = NULL; |
| 525 | int i; |
| 526 | |
| 527 | for (i = 0; i < aliases->nelts; ++i) { |
| 528 | alias_entry *alias = &entries[i]; |
| 529 | int l; |
| 530 | |
| 531 | if (alias->regexp) { |
| 532 | if (!ap_regexec(alias->regexp, r->uri, AP_MAX_REG_MATCH, regm, 0)) { |
| 533 | if (alias->real) { |
| 534 | found = ap_pregsub(r->pool, alias->real, r->uri, |
| 535 | AP_MAX_REG_MATCH, regm); |
| 536 | if (found) { |
| 537 | if (is_redir) { |
| 538 | apr_uri_t uri; |
| 539 | apr_uri_parse(r->pool, found, &uri); |
| 540 | /* Do not escape the query string or fragment. */ |
| 541 | found = apr_uri_unparse(r->pool, &uri, |
| 542 | APR_URI_UNP_OMITQUERY); |
| 543 | found = ap_escape_uri(r->pool, found); |
| 544 | if (uri.query) { |
| 545 | found = apr_pstrcat(r->pool, found, "?", |
| 546 | uri.query, NULL); |
| 547 | } |
| 548 | if (uri.fragment) { |
| 549 | found = apr_pstrcat(r->pool, found, "#", |
| 550 | uri.fragment, NULL); |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | else { |
| 555 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00672) |
| 556 | "Regex substitution in '%s' failed. " |
| 557 | "Replacement too long?", alias->real); |
| 558 | return PREGSUB_ERROR; |
| 559 | } |
| 560 | } |
| 561 | else { |
| 562 | /* need something non-null */ |
| 563 | found = ""; |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | else { |
| 568 | l = alias_matches(r->uri, alias->fake); |
| 569 | |
| 570 | if (l > 0) { |
| 571 | ap_set_context_info(r, alias->fake, alias->real); |
| 572 | if (is_redir) { |
| 573 | char *escurl; |
| 574 | escurl = ap_os_escape_path(r->pool, r->uri + l, 1); |
| 575 | |
| 576 | found = apr_pstrcat(r->pool, alias->real, escurl, NULL); |
no test coverage detected