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

Function alias_match

modules/proxy/mod_proxy.c:532–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530}
531
532static int alias_match(const char *uri, const char *alias_fakename)
533{
534 const char *end_fakename = alias_fakename + strlen(alias_fakename);
535 const char *aliasp = alias_fakename, *urip = uri;
536 const char *end_uri = uri + strlen(uri);
537
538 while (aliasp < end_fakename && urip < end_uri) {
539 if (*aliasp == '/') {
540 /* any number of '/' in the alias matches any number in
541 * the supplied URI, but there must be at least one...
542 */
543 if (*urip != '/')
544 return 0;
545
546 while (*aliasp == '/')
547 ++aliasp;
548 while (*urip == '/')
549 ++urip;
550 }
551 else {
552 /* Other characters are compared literally */
553 if (*urip++ != *aliasp++)
554 return 0;
555 }
556 }
557
558 /* fixup badly encoded stuff (e.g. % as last character) */
559 if (aliasp > end_fakename) {
560 aliasp = end_fakename;
561 }
562 if (urip > end_uri) {
563 urip = end_uri;
564 }
565
566 /* We reach the end of the uri before the end of "alias_fakename"
567 * for example uri is "/" and alias_fakename "/examples"
568 */
569 if (urip == end_uri && aliasp != end_fakename) {
570 return 0;
571 }
572
573 /* Check last alias path component matched all the way */
574 if (aliasp[-1] != '/' && *urip != '\0' && *urip != '/')
575 return 0;
576
577 /* Return number of characters from URI which matched (may be
578 * greater than length of alias, since we may have matched
579 * doubled slashes)
580 */
581
582 return urip - uri;
583}
584
585/*
586 * Inspired by mod_jk's jk_servlet_normalize().

Callers 1

ap_proxy_trans_matchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected