commit a22989555dc1675d7f1fad31f4b397ec17d462e2 from: Omar Polo date: Thu Aug 31 15:25:17 2023 UTC amused-web: strip the query from the request path commit - c2117f4b55aab1b09cef4ca3ed556d54c7e7ce2a commit + a22989555dc1675d7f1fad31f4b397ec17d462e2 blob - 4c3e423974b0b9924fe695c48c9825dfccb57fdc blob + 32f5b11fdb697d9dfa13493dcb4233c0fb0a8f5d --- web/http.c +++ web/http.c @@ -62,7 +62,7 @@ http_parse(struct client *clt) struct request *req = &clt->req; size_t len; uint8_t *endln; - char *t, *line; + char *frag, *query, *t, *line; const char *errstr, *m; while (!clt->reqdone) { @@ -99,7 +99,14 @@ http_parse(struct client *clt) t = line; if (*t != '\0') *t++ = '\0'; + + if ((query = strchr(line, '?'))) + *query = '\0'; + if ((frag = strchr(line, '#'))) + *frag = '\0'; + clt->req.path = xstrdup(line); + if (!strcmp(t, "HTTP/1.0")) clt->req.version = HTTP_1_0; else if (!strcmp(t, "HTTP/1.1")) {