ce40e23f075832f24396e2c2638ee1dfad83acca galt Tue Feb 4 17:26:46 2014 -0800 Fixes #12630. This addresses a bug in + handling in FTP URLs which only have a path part and no query part. Added cgiDecodeFull function to parallel the existing cgiEncodeFull function. These functions ignore the + character when encoding. diff --git src/lib/cheapcgi.c src/lib/cheapcgi.c index 22cfc26..9f98315 100644 --- src/lib/cheapcgi.c +++ src/lib/cheapcgi.c @@ -940,30 +940,55 @@ else if (c == '%') { int code; if (sscanf(in, "%2x", &code) != 1) code = '?'; in += 2; i += 2; *out++ = code; } else *out++ = c; } *out++ = 0; } +void cgiDecodeFull(char *in, char *out, int inLength) +/* Out will be a cgi-decoded version of in (no space from plus!). + * Out will be a little shorter than in typically, and + * can be the same buffer. */ +{ +char c; +int i; +for (i=0; i<inLength;++i) + { + c = *in++; + if (c == '%') + { + int code; + if (sscanf(in, "%2x", &code) != 1) + code = '?'; + in += 2; + i += 2; + *out++ = code; + } + else + *out++ = c; + } +*out++ = 0; +} + char *cgiEncode(char *inString) /* Return a cgi-encoded version of inString. * Alphanumerics kept as is, space translated to plus, * and all other characters translated to %hexVal. */ { char c; int outSize = 0; char *outString, *out, *in; if (inString == NULL) return(cloneString("")); /* Count up how long it will be */ in = inString; while ((c = *in++) != 0)