Clean up the whitespace encoding code.

This commit is contained in:
Dag-Erling Smørgrav 2000-12-01 11:04:57 +00:00
parent 025bb05a82
commit f9c2053bca
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69465

View File

@ -294,7 +294,7 @@ fetchMakeURL(char *scheme, char *host, int port, char *doc,
struct url * struct url *
fetchParseURL(char *URL) fetchParseURL(char *URL)
{ {
char *p, *q; char *doc, *p, *q;
struct url *u; struct url *u;
int i; int i;
@ -367,15 +367,16 @@ fetchParseURL(char *URL)
if (!*p) if (!*p)
p = "/"; p = "/";
if (strcmp(u->scheme, "http") == 0 || strcmp(u->scheme, "https") == 0) { if (strcasecmp(u->scheme, SCHEME_HTTP) == 0 ||
strcasecmp(u->scheme, SCHEME_HTTPS) == 0) {
const char hexnums[] = "0123456789abcdef"; const char hexnums[] = "0123456789abcdef";
char *doc;
/* Perform %hh encoding of white space. */ /* percent-escape whitespace. */
if ((doc = u->doc = malloc(strlen(p) * 3 + 1)) == NULL) { if ((doc = malloc(strlen(p) * 3 + 1)) == NULL) {
_fetch_syserr(); _fetch_syserr();
goto ouch; goto ouch;
} }
u->doc = doc;
while (*p != '\0') { while (*p != '\0') {
if (!isspace(*p)) { if (!isspace(*p)) {
*doc++ = *p++; *doc++ = *p++;