Handling include= for mod_include. */
| 1641 | |
| 1642 | /* Handling include= for mod_include. */ |
| 1643 | static apr_status_t include_cgi(include_ctx_t *ctx, ap_filter_t *f, |
| 1644 | apr_bucket_brigade *bb, char *s) |
| 1645 | { |
| 1646 | request_rec *r = f->r; |
| 1647 | request_rec *rr = ap_sub_req_lookup_uri(s, r, f->next); |
| 1648 | int rr_status; |
| 1649 | |
| 1650 | if (rr->status != HTTP_OK) { |
| 1651 | ap_destroy_sub_req(rr); |
| 1652 | return APR_EGENERAL; |
| 1653 | } |
| 1654 | |
| 1655 | /* No hardwired path info or query allowed */ |
| 1656 | if ((rr->path_info && rr->path_info[0]) || rr->args) { |
| 1657 | ap_destroy_sub_req(rr); |
| 1658 | return APR_EGENERAL; |
| 1659 | } |
| 1660 | if (rr->finfo.filetype != APR_REG) { |
| 1661 | ap_destroy_sub_req(rr); |
| 1662 | return APR_EGENERAL; |
| 1663 | } |
| 1664 | |
| 1665 | /* Script gets parameters of the *document*, for back compatibility */ |
| 1666 | rr->path_info = r->path_info; /* hard to get right; see mod_cgi.c */ |
| 1667 | rr->args = r->args; |
| 1668 | |
| 1669 | /* Force sub_req to be treated as a CGI request, even if ordinary |
| 1670 | * typing rules would have called it something else. |
| 1671 | */ |
| 1672 | ap_set_content_type_ex(rr, CGI_MAGIC_TYPE, 1); |
| 1673 | |
| 1674 | /* Run it. */ |
| 1675 | rr_status = ap_run_sub_req(rr); |
| 1676 | if (ap_is_HTTP_REDIRECT(rr_status)) { |
| 1677 | const char *location = apr_table_get(rr->headers_out, "Location"); |
| 1678 | |
| 1679 | if (location) { |
| 1680 | char *buffer; |
| 1681 | |
| 1682 | location = ap_escape_html(rr->pool, location); |
| 1683 | buffer = apr_pstrcat(ctx->pool, "<a href=\"", location, "\">", |
| 1684 | location, "</a>", NULL); |
| 1685 | |
| 1686 | APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(buffer, |
| 1687 | strlen(buffer), ctx->pool, |
| 1688 | f->c->bucket_alloc)); |
| 1689 | } |
| 1690 | } |
| 1691 | |
| 1692 | ap_destroy_sub_req(rr); |
| 1693 | |
| 1694 | return APR_SUCCESS; |
| 1695 | } |
| 1696 | |
| 1697 | /* This is the special environment used for running the "exec cmd=" |
| 1698 | * variety of SSI directives. |
nothing calls this directly
no test coverage detected