Commit b01d0ce3 authored by Tim Rühsen's avatar Tim Rühsen

* libwget/http_parse.c (wget_http_parse_location): Being more lenient

Some servers don't percent encode the URI in a Location: header.
Having spaces in the URI leads to magled file names and likely 404.

Fixes #420
parent 88b99f0e
......@@ -424,7 +424,17 @@ const char *wget_http_parse_location(const char *s, const char **location)
while (c_isblank(*s)) s++;
for (p = s; *s && !c_isblank(*s); s++);
/*
* The correct (and still lenient) variant was:
* for (p = s; *s && !c_isblank(*s); s++);
*
* And then there were spaces in the URI, see
* https://gitlab.com/gnuwget/wget2/issues/420
*/
for (p = s; *s && *s != '\r' && *s != '\n'; s++);
while (s > p && c_isdigit(*(s - 1))) s--; // remove trailing spaces (OWS - optional white space)
*location = wget_strmemdup(p, s - p);
return s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment