MCPcopy Create free account
hub / github.com/apache/httpd / try_alias_list

Function try_alias_list

modules/mappers/mod_alias.c:519–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519static 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);

Callers 2

translate_alias_redirFunction · 0.85
fixup_redirFunction · 0.85

Calls 6

ap_regexecFunction · 0.85
ap_pregsubFunction · 0.85
alias_matchesFunction · 0.85
ap_set_context_infoFunction · 0.85
ap_os_escape_pathFunction · 0.85
ap_server_root_relativeFunction · 0.85

Tested by

no test coverage detected