* 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. */
| 28 | * def_port is the default port for this scheme. |
| 29 | */ |
| 30 | static int proxy_ajp_canon(request_rec *r, char *url) |
| 31 | { |
| 32 | char *host, *path, sport[7]; |
| 33 | char *search = NULL; |
| 34 | const char *err; |
| 35 | apr_port_t port, def_port; |
| 36 | |
| 37 | /* ap_port_of_scheme() */ |
| 38 | if (ap_cstr_casecmpn(url, "ajp:", 4) == 0) { |
| 39 | url += 4; |
| 40 | } |
| 41 | else { |
| 42 | return DECLINED; |
| 43 | } |
| 44 | |
| 45 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "canonicalising URL %s", url); |
| 46 | |
| 47 | /* |
| 48 | * do syntactic check. |
| 49 | * We break the URL into host, port, path, search |
| 50 | */ |
| 51 | port = def_port = ap_proxy_port_of_scheme("ajp"); |
| 52 | |
| 53 | err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port); |
| 54 | if (err) { |
| 55 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00867) "error parsing URL %s: %s", |
| 56 | url, err); |
| 57 | return HTTP_BAD_REQUEST; |
| 58 | } |
| 59 | |
| 60 | /* |
| 61 | * now parse path/search args, according to rfc1738: |
| 62 | * process the path. With proxy-nocanon set (by |
| 63 | * mod_proxy) we use the raw, unparsed uri |
| 64 | */ |
| 65 | if (apr_table_get(r->notes, "proxy-nocanon")) { |
| 66 | path = url; /* this is the raw path */ |
| 67 | } |
| 68 | else if (apr_table_get(r->notes, "proxy-noencode")) { |
| 69 | path = url; /* this is the encoded path already */ |
| 70 | search = r->args; |
| 71 | } |
| 72 | else { |
| 73 | core_dir_config *d = ap_get_core_module_config(r->per_dir_config); |
| 74 | int flags = d->allow_encoded_slashes && !d->decode_encoded_slashes ? PROXY_CANONENC_NOENCODEDSLASHENCODING : 0; |
| 75 | |
| 76 | path = ap_proxy_canonenc_ex(r->pool, url, strlen(url), enc_path, flags, |
| 77 | r->proxyreq); |
| 78 | if (!path) { |
| 79 | return HTTP_BAD_REQUEST; |
| 80 | } |
| 81 | search = r->args; |
| 82 | } |
| 83 | /* |
| 84 | * If we have a raw control character or a ' ' in nocanon path or |
| 85 | * r->args, correct encoding was missed. |
| 86 | */ |
| 87 | if (path == url && *ap_scan_vchar_obstext(path)) { |
nothing calls this directly
no test coverage detected