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

Function ap_proxy_canon_netloc

modules/proxy/proxy_util.c:341–410  ·  view source on GitHub ↗

* Parses network-location. * urlp on input the URL; on output the path, after the leading / * user NULL if no user/password permitted * password holder for password * host holder for host * port port number; only set if one is supplied. * * Returns an error string. */

Source from the content-addressed store, hash-verified

339 * Returns an error string.
340 */
341PROXY_DECLARE(char *)
342 ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
343 char **passwordp, char **hostp, apr_port_t *port)
344{
345 char *addr, *scope_id, *strp, *host, *url = *urlp;
346 char *user = NULL, *password = NULL;
347 apr_port_t tmp_port;
348 apr_status_t rv;
349
350 if (url[0] != '/' || url[1] != '/') {
351 return "Malformed URL";
352 }
353 host = url + 2;
354 url = strchr(host, '/');
355 if (url == NULL) {
356 url = "";
357 }
358 else {
359 *(url++) = '\0'; /* skip separating '/' */
360 }
361
362 /* find _last_ '@' since it might occur in user/password part */
363 strp = strrchr(host, '@');
364
365 if (strp != NULL) {
366 *strp = '\0';
367 user = host;
368 host = strp + 1;
369
370/* find password */
371 strp = strchr(user, ':');
372 if (strp != NULL) {
373 *strp = '\0';
374 password = ap_proxy_canonenc(p, strp + 1, strlen(strp + 1), enc_user, 1, 0);
375 if (password == NULL) {
376 return "Bad %-escape in URL (password)";
377 }
378 }
379
380 user = ap_proxy_canonenc(p, user, strlen(user), enc_user, 1, 0);
381 if (user == NULL) {
382 return "Bad %-escape in URL (username)";
383 }
384 }
385 if (userp != NULL) {
386 *userp = user;
387 }
388 if (passwordp != NULL) {
389 *passwordp = password;
390 }
391
392 /*
393 * Parse the host string to separate host portion from optional port.
394 * Perform range checking on port.
395 */
396 rv = apr_parse_addr_port(&addr, &scope_id, &tmp_port, host, p);
397 if (rv != APR_SUCCESS || addr == NULL || scope_id != NULL) {
398 return "Invalid host/port";

Callers 10

proxy_fcgi_canonFunction · 0.85
proxy_http_canonFunction · 0.85
proxy_balancer_canonFunction · 0.85
uwsgi_canonFunction · 0.85
proxy_wstunnel_canonFunction · 0.85
proxy_ftp_canonFunction · 0.85
proxy_ajp_canonFunction · 0.85
scgi_canonFunction · 0.85
proxy_http2_canonFunction · 0.85

Calls 2

ap_proxy_canonencFunction · 0.85
ap_str_tolowerFunction · 0.85

Tested by

no test coverage detected