From 35acbfe0b39fd6099d0a015c291e0d16d3588532 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 17 Jul 2001 20:22:33 +0000 Subject: [PATCH] Unbreak parsing URLs that have a host part but no document part. While we're here, fix a snprintf() usage warning. --- lib/libfetch/fetch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index 303861a956bc..963557b34b90 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -307,7 +307,7 @@ fetchParseURL(const char *URL) /* scheme name */ if ((p = strstr(URL, ":/"))) { - snprintf(u->scheme, URL_SCHEMELEN+1, "%.*s", p - URL, URL); + snprintf(u->scheme, URL_SCHEMELEN+1, "%.*s", (int)(p - URL), URL); URL = ++p; /* * Only one slash: no host, leave slash as part of document @@ -318,7 +318,8 @@ fetchParseURL(const char *URL) } else { p = URL; } - if (!*URL || *URL == '/' || *URL == '.' || strchr(URL, '/') == NULL) + if (!*URL || *URL == '/' || *URL == '.' || + (u->scheme[0] == '\0' && strchr(URL, '/') == NULL)) goto nohost; p = strpbrk(URL, "/@");