diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2000-10-21 14:58:18 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2000-10-21 14:58:18 +0000 |
| commit | 23fe6d7a4c20187171a175e7e5202fad6e69bafc (patch) | |
| tree | 56378518d92d8c2ef85369bfa903b352c061595b /lib/libfetch/fetch.c | |
| parent | f3581390d2c9123caf199c503827d7071a1b6d4c (diff) | |
Notes
Diffstat (limited to 'lib/libfetch/fetch.c')
| -rw-r--r-- | lib/libfetch/fetch.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index e79dba83b0ab..b814336285b3 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; } |
