mirror of
https://github.com/curl/curl.git
synced 2025-09-15 00:22:42 +03:00
tool: avoid including leading spaces in the Location hyperlink
Co-authored-by: Dan Fandrich <dan@coneharvesters.com> Closes #11735
This commit is contained in:
parent
86bbb57e31
commit
226d042a58
|
@ -349,6 +349,7 @@ void write_linked_location(CURL *curl, const char *location, size_t loclen,
|
||||||
char *copyloc = NULL, *locurl = NULL, *scheme = NULL, *finalurl = NULL;
|
char *copyloc = NULL, *locurl = NULL, *scheme = NULL, *finalurl = NULL;
|
||||||
const char *loc = location;
|
const char *loc = location;
|
||||||
size_t llen = loclen;
|
size_t llen = loclen;
|
||||||
|
int space_skipped = 0;
|
||||||
char *vver = getenv("VTE_VERSION");
|
char *vver = getenv("VTE_VERSION");
|
||||||
|
|
||||||
if(vver) {
|
if(vver) {
|
||||||
|
@ -360,9 +361,10 @@ void write_linked_location(CURL *curl, const char *location, size_t loclen,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strip leading whitespace of the redirect URL */
|
/* Strip leading whitespace of the redirect URL */
|
||||||
while(llen && *loc == ' ') {
|
while(llen && (*loc == ' ' || *loc == '\t')) {
|
||||||
++loc;
|
++loc;
|
||||||
--llen;
|
--llen;
|
||||||
|
++space_skipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strip the trailing end-of-line characters, normally "\r\n" */
|
/* Strip the trailing end-of-line characters, normally "\r\n" */
|
||||||
|
@ -401,8 +403,10 @@ void write_linked_location(CURL *curl, const char *location, size_t loclen,
|
||||||
!strcmp("https", scheme) ||
|
!strcmp("https", scheme) ||
|
||||||
!strcmp("ftp", scheme) ||
|
!strcmp("ftp", scheme) ||
|
||||||
!strcmp("ftps", scheme)) {
|
!strcmp("ftps", scheme)) {
|
||||||
fprintf(stream, LINK "%s" LINKST "%.*s" LINKOFF,
|
fprintf(stream, "%.*s" LINK "%s" LINKST "%.*s" LINKOFF,
|
||||||
finalurl, (int)loclen, location);
|
space_skipped, location,
|
||||||
|
finalurl,
|
||||||
|
(int)loclen - space_skipped, loc);
|
||||||
goto locdone;
|
goto locdone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user