* Canonicalise http-like URLs. * scheme is the scheme for the URL * url is the URL starting with the first '/' * def_port is the default port for this scheme. */
| 56 | * def_port is the default port for this scheme. |
| 57 | */ |
| 58 | static int proxy_fcgi_canon(request_rec *r, char *url) |
| 59 | { |
| 60 | char *host, sport[7]; |
| 61 | const char *err; |
| 62 | char *path; |
| 63 | apr_port_t port, def_port; |
| 64 | fcgi_req_config_t *rconf = NULL; |
| 65 | const char *pathinfo_type = NULL; |
| 66 | fcgi_dirconf_t *dconf = ap_get_module_config(r->per_dir_config, |
| 67 | &proxy_fcgi_module); |
| 68 | |
| 69 | if (ap_cstr_casecmpn(url, "fcgi:", 5) == 0) { |
| 70 | url += 5; |
| 71 | } |
| 72 | else { |
| 73 | return DECLINED; |
| 74 | } |
| 75 | |
| 76 | port = def_port = ap_proxy_port_of_scheme("fcgi"); |
| 77 | |
| 78 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, |
| 79 | "canonicalising URL %s", url); |
| 80 | err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port); |
| 81 | if (err) { |
| 82 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01059) |
| 83 | "error parsing URL %s: %s", url, err); |
| 84 | return HTTP_BAD_REQUEST; |
| 85 | } |
| 86 | |
| 87 | if (port != def_port) |
| 88 | apr_snprintf(sport, sizeof(sport), ":%d", port); |
| 89 | else |
| 90 | sport[0] = '\0'; |
| 91 | |
| 92 | if (ap_strchr_c(host, ':')) { |
| 93 | /* if literal IPv6 address */ |
| 94 | host = apr_pstrcat(r->pool, "[", host, "]", NULL); |
| 95 | } |
| 96 | |
| 97 | if (apr_table_get(r->notes, "proxy-sethandler") |
| 98 | || apr_table_get(r->notes, "proxy-nocanon") |
| 99 | || apr_table_get(r->notes, "proxy-noencode")) { |
| 100 | char *c = url; |
| 101 | |
| 102 | /* We do not call ap_proxy_canonenc_ex() on the path here, don't |
| 103 | * let control characters pass still, and for php-fpm no '?' either. |
| 104 | */ |
| 105 | if (FCGI_MAY_BE_FPM(dconf)) { |
| 106 | while (!apr_iscntrl(*c) && *c != '?') |
| 107 | c++; |
| 108 | } |
| 109 | else { |
| 110 | while (!apr_iscntrl(*c)) |
| 111 | c++; |
| 112 | } |
| 113 | if (*c) { |
| 114 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10414) |
| 115 | "To be forwarded path contains control characters%s (%s)", |
nothing calls this directly
no test coverage detected