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

Function subst_prefix_path

modules/mappers/mod_rewrite.c:1074–1113  ·  view source on GitHub ↗

* substitute the prefix path 'match' in 'input' with 'subst' (RewriteBase) */

Source from the content-addressed store, hash-verified

1072 * substitute the prefix path 'match' in 'input' with 'subst' (RewriteBase)
1073 */
1074static char *subst_prefix_path(request_rec *r, char *input, const char *match,
1075 const char *subst)
1076{
1077 apr_size_t len = strlen(match);
1078
1079 if (len && match[len - 1] == '/') {
1080 --len;
1081 }
1082
1083 if (!strncmp(input, match, len) && input[len++] == '/') {
1084 apr_size_t slen, outlen;
1085 char *output;
1086
1087 rewritelog(r, 5, NULL, "strip matching prefix: %s -> %s", input,
1088 input+len);
1089
1090 slen = strlen(subst);
1091 if (slen && subst[slen - 1] != '/') {
1092 ++slen;
1093 }
1094
1095 outlen = strlen(input) + slen - len;
1096 output = apr_palloc(r->pool, outlen + 1); /* don't forget the \0 */
1097
1098 memcpy(output, subst, slen);
1099 if (slen && !output[slen-1]) {
1100 output[slen-1] = '/';
1101 }
1102 memcpy(output+slen, input+len, outlen - slen);
1103 output[outlen] = '\0';
1104
1105 rewritelog(r, 4, NULL, "add subst prefix: %s -> %s", input+len,
1106 output);
1107
1108 return output;
1109 }
1110
1111 /* prefix didn't match */
1112 return input;
1113}
1114
1115
1116/*

Callers 1

hook_fixupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected