14bd0ebc30e0b9436ed376bfffd238bf2a659c08 galt Fri Feb 14 10:55:09 2014 -0800 adding a helpful explanatory comment about which kind of encode function to use on which part of the url diff --git src/lib/cheapcgi.c src/lib/cheapcgi.c index 9f98315..b475514 100644 --- src/lib/cheapcgi.c +++ src/lib/cheapcgi.c @@ -913,30 +913,45 @@ || c == '\n' || c == '\r' || c == '\t' || c == '\b' || c == '\f' ) *out++ = '\\'; *out++ = c; } *out++ = 0; return outString; } +/* NOTE: Where in the URL to use which of these functions: + * + * Parts of a URL: + * protocol://user:password@server.com:port/path/filename?var1=val1&var2=val2 + * + * Note that a space should only be encoded to a plus and decoded from a plus + * when dealing with http URLs in the query part of the string, + * which is the part after the ? above. + * It should not be used in the rest of the URL. + * So in the query string part of a URL, do use cgiEncode/cgiDecode. + * And in the rest of the URL, use cgiEncodeFUll/cgiDecodeFull + * which do not code space as plus. + * Since FTP does not use URLs with query parameters, use the Full version. + */ + void cgiDecode(char *in, char *out, int inLength) /* Decode from cgi pluses-for-spaces format to normal. * Out will be a little shorter than in typically, and * can be the same buffer. */ { char c; int i; for (i=0; i