* Cookies are a bit trickier to match: we've got two substrings to worry * about, and we can't just find them with strstr 'cos of case. Regexp * matching would be an easy fix, but for better consistency with all the * other matches we'll refrain and use apr_strmatch to find path=/domain= * and stick to plain strings for the config values. */
| 998 | * and stick to plain strings for the config values. |
| 999 | */ |
| 1000 | PROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, |
| 1001 | proxy_dir_conf *conf, const char *str) |
| 1002 | { |
| 1003 | proxy_req_conf *rconf = ap_get_module_config(r->request_config, |
| 1004 | &proxy_module); |
| 1005 | struct proxy_alias *ent; |
| 1006 | apr_size_t len = strlen(str); |
| 1007 | const char *newpath = NULL; |
| 1008 | const char *newdomain = NULL; |
| 1009 | const char *pathp; |
| 1010 | const char *domainp; |
| 1011 | const char *pathe = NULL; |
| 1012 | const char *domaine = NULL; |
| 1013 | apr_size_t l1, l2, poffs = 0, doffs = 0; |
| 1014 | int i; |
| 1015 | int ddiff = 0; |
| 1016 | int pdiff = 0; |
| 1017 | char *tmpstr, *tmpstr_orig, *token, *last, *ret; |
| 1018 | |
| 1019 | if (r->proxyreq != PROXYREQ_REVERSE) { |
| 1020 | return str; |
| 1021 | } |
| 1022 | |
| 1023 | /* |
| 1024 | * Find the match and replacement, but save replacing until we've done |
| 1025 | * both path and domain so we know the new strlen |
| 1026 | */ |
| 1027 | tmpstr_orig = tmpstr = apr_pstrdup(r->pool, str); |
| 1028 | while ((token = apr_strtok(tmpstr, ";", &last))) { |
| 1029 | /* skip leading spaces */ |
| 1030 | while (apr_isspace(*token)) { |
| 1031 | ++token; |
| 1032 | } |
| 1033 | |
| 1034 | if (ap_cstr_casecmpn("path=", token, 5) == 0) { |
| 1035 | pathp = token + 5; |
| 1036 | poffs = pathp - tmpstr_orig; |
| 1037 | l1 = strlen(pathp); |
| 1038 | pathe = str + poffs + l1; |
| 1039 | /* |
| 1040 | * RFC 6265 § 5.3 7): Only the last path= should be meaningful |
| 1041 | * so reset anything previously found. |
| 1042 | */ |
| 1043 | newpath = NULL; |
| 1044 | pdiff = 0; |
| 1045 | if (conf->interpolate_env == 1) { |
| 1046 | ent = (struct proxy_alias *)rconf->cookie_paths->elts; |
| 1047 | } |
| 1048 | else { |
| 1049 | ent = (struct proxy_alias *)conf->cookie_paths->elts; |
| 1050 | } |
| 1051 | for (i = 0; i < conf->cookie_paths->nelts; i++) { |
| 1052 | l2 = strlen(ent[i].fake); |
| 1053 | if (l1 >= l2 && strncmp(ent[i].fake, pathp, l2) == 0) { |
| 1054 | newpath = ent[i].real; |
| 1055 | pdiff = strlen(newpath) - l1; |
| 1056 | break; |
| 1057 | } |
no test coverage detected