Hi,
I attached 3 patchs:
- retry.patch: move name of output file outside the retry loop. Should
keep the filename defined by user, instead of pike one from server.
- spell.patch: correct a small spelling error
- url-user.patch: a small change in url_parse() in order to copte with
@ char in url path (http://example.com/my@funny@path isn't well
parsed)
And another note, the url_parse() don't copte with url in ipv6
(for example http://[2a00:1450:4007:807::1010]:80/), but I don't known
if it is a real issue for now.
Thanks.
--
Sebastien Marie
Index: b/main.c
===================================================================
--- a/main.c 2015-08-16 10:00:25.000000000 +0200
+++ b/main.c 2015-08-17 18:48:08.951532825 +0200
@@ -108,8 +108,8 @@ main(int argc, char *argv[])
}
for (i = 0; i < argc; i++) {
-retry:
fn = (output) ? output : basename(argv[i]);
+retry:
url_str = url_encode(argv[i]);
p = url_type(url_str);
if (url_parse(url_str, &url, p) != 0)
Index: b/main.c
===================================================================
--- a/main.c 2015-08-17 18:48:08.951532825 +0200
+++ b/main.c 2015-08-17 19:32:54.811047138 +0200
@@ -119,7 +119,7 @@ retry:
(void)strlcpy(url.port, port, sizeof(url.port));
if (strcmp(url.path, "/") == 0 || strlen(url.path) == 0)
- errx(1, "No filename afer host: %s", url.host);
+ errx(1, "No filename after host: %s", url.host);
if (url_connect(&url, pproxy) == -1)
return (-1);
Index: b/util.c
===================================================================
--- a/util.c 2015-08-17 19:29:39.239294584 +0200
+++ b/util.c 2015-08-17 19:37:40.483642472 +0200
@@ -198,6 +198,16 @@ url_parse(const char *url_str, struct ur
else
s = curl;
+ /* extract url path */
+ if ((e = strchr(s, '/'))) {
+ if (strlcpy(url->path, e,
+ sizeof(url->path)) >= sizeof(url->path)) {
+ warnx("url_parse: path overflow");
+ goto cleanup;
+ }
+ *e = '\0';
+ }
+
/* extract user and password */
if ((e = strchr(s, '@'))) {
*e++ = '\0';
@@ -221,16 +231,6 @@ url_parse(const char *url_str, struct ur
s = e;
}
- /* extract url path */
- if ((e = strchr(s, '/'))) {
- if (strlcpy(url->path, e,
- sizeof(url->path)) >= sizeof(url->path)) {
- warnx("url_parse: path overflow");
- goto cleanup;
- }
- *e = '\0';
- }
-
/* extract url port */
if ((t = strchr(s, ':'))) {
*t++ = '\0';