wget: handle URLs with @ or hash differently
If server replied with 302 and Location: ?foo we used to underflow the allocated space while trying to form the "@foo" filename. Switch to forming "foo" filename. function old new delta packed_usage 32795 32799 +4 parse_url 387 352 -35 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-35) Total: -31 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
f4eaccbfae
commit
df45eb49ac
@ -539,7 +539,7 @@ static void parse_url(const char *src_url, struct host_info *h)
|
|||||||
// and saves 'index.html?var=a%2Fb' (we save 'b')
|
// and saves 'index.html?var=a%2Fb' (we save 'b')
|
||||||
// wget 'http://busybox.net?login=john@doe':
|
// wget 'http://busybox.net?login=john@doe':
|
||||||
// request: 'GET /?login=john@doe HTTP/1.0'
|
// request: 'GET /?login=john@doe HTTP/1.0'
|
||||||
// saves: 'index.html?login=john@doe' (we save '?login=john@doe')
|
// saves: 'index.html?login=john@doe' (we save 'login=john@doe')
|
||||||
// wget 'http://busybox.net#test/test':
|
// wget 'http://busybox.net#test/test':
|
||||||
// request: 'GET / HTTP/1.0'
|
// request: 'GET / HTTP/1.0'
|
||||||
// saves: 'index.html' (we save 'test')
|
// saves: 'index.html' (we save 'test')
|
||||||
@ -553,13 +553,13 @@ static void parse_url(const char *src_url, struct host_info *h)
|
|||||||
} else if (*sp == '/') {
|
} else if (*sp == '/') {
|
||||||
*sp = '\0';
|
*sp = '\0';
|
||||||
h->path = sp + 1;
|
h->path = sp + 1;
|
||||||
} else { // '#' or '?'
|
} else {
|
||||||
|
// sp points to '#' or '?'
|
||||||
|
// Note:
|
||||||
// http://busybox.net?login=john@doe is a valid URL
|
// http://busybox.net?login=john@doe is a valid URL
|
||||||
// memmove converts to:
|
// (without '/' between ".net" and "?"),
|
||||||
// http:/busybox.nett?login=john@doe...
|
// can't store NUL at sp[-1] - this destroys hostname.
|
||||||
memmove(h->host - 1, h->host, sp - h->host);
|
*sp++ = '\0';
|
||||||
h->host--;
|
|
||||||
sp[-1] = '\0';
|
|
||||||
h->path = sp;
|
h->path = sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user