From cbb8cbedb3f4e6af0fd2457326f543adb2638fc8 Mon Sep 17 00:00:00 2001 From: des Date: Sat, 21 Oct 2000 14:58:18 +0000 Subject: If the scheme is HTTP or HTTPS, percent-escape whitespace in the document part. Submitted by: green --- lib/libfetch/fetch.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/libfetch') diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index e79dba8..b814336 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -367,7 +367,27 @@ nohost: if (!*p) p = "/"; - if ((u->doc = strdup(p)) == NULL) { + if (strcmp(u->scheme, "http") == 0 || strcmp(u->scheme, "https") == 0) { + const char hexnums[] = "0123456789abcdef"; + char *doc; + + /* Perform %hh encoding of white space. */ + if ((doc = u->doc = malloc(strlen(p) * 3 + 1)) == NULL) { + _fetch_syserr(); + goto ouch; + } + while (*p != '\0') { + if (!isspace(*p)) { + *doc++ = *p++; + } else { + *doc++ = '%'; + *doc++ = hexnums[((unsigned int)*p) >> 4]; + *doc++ = hexnums[((unsigned int)*p) & 0xf]; + p++; + } + } + *doc = '\0'; + } else if ((u->doc = strdup(p)) == NULL) { _fetch_syserr(); goto ouch; } -- cgit v1.1