diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -1593,6 +1593,7 @@ off_t offset, clength, length, size; time_t mtime; const char *p; + char *fragment; FILE *f; hdr_t h; struct tm *timestruct; @@ -1632,6 +1633,13 @@ size = -1; mtime = 0; + /* fragments are reserved for client-side processing, see + * https://www.rfc-editor.org/rfc/rfc9110.html#section-7.1 + */ + if ((fragment = strchr(url->doc, '#')) != NULL) { + *fragment = '\0'; + } + /* check port */ if (!url->port) url->port = fetch_default_port(url->scheme);