http: remove multi-/ from URL when searching for paths (fixes #1764)
This commit is contained in:
parent
066728b9a0
commit
4f054fb41f
1 changed files with 23 additions and 8 deletions
27
src/http.c
27
src/http.c
|
@ -69,19 +69,34 @@ static http_path_t *
|
||||||
http_resolve(http_connection_t *hc, char **remainp, char **argsp)
|
http_resolve(http_connection_t *hc, char **remainp, char **argsp)
|
||||||
{
|
{
|
||||||
http_path_t *hp;
|
http_path_t *hp;
|
||||||
char *v;
|
int n = 0;
|
||||||
|
char *v, *path = tvh_strdupa(hc->hc_url);
|
||||||
|
|
||||||
|
/* Canocalize path (or at least remove excess slashes) */
|
||||||
|
v = path;
|
||||||
|
while (*v && *v != '?') {
|
||||||
|
if (*v == '/' && v[1] == '/') {
|
||||||
|
int l = strlen(v+1);
|
||||||
|
memmove(v, v+1, l);
|
||||||
|
v[l] = 0;
|
||||||
|
n++;
|
||||||
|
} else
|
||||||
|
v++;
|
||||||
|
}
|
||||||
|
|
||||||
LIST_FOREACH(hp, &http_paths, hp_link) {
|
LIST_FOREACH(hp, &http_paths, hp_link) {
|
||||||
if(!strncmp(hc->hc_url, hp->hp_path, hp->hp_len)) {
|
if(!strncmp(path, hp->hp_path, hp->hp_len)) {
|
||||||
if(hc->hc_url[hp->hp_len] == 0 || hc->hc_url[hp->hp_len] == '/' ||
|
if(path[hp->hp_len] == 0 ||
|
||||||
hc->hc_url[hp->hp_len] == '?')
|
path[hp->hp_len] == '/' ||
|
||||||
break;
|
path[hp->hp_len] == '?')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hp == NULL)
|
if(hp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
v = hc->hc_url + hp->hp_len;
|
v = hc->hc_url + n + hp->hp_len;
|
||||||
|
|
||||||
*remainp = NULL;
|
*remainp = NULL;
|
||||||
*argsp = NULL;
|
*argsp = NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue