From 1fcc9e1f6d2a6ee3f170055692cbfbe7432cf7ee Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 24 Sep 2001 04:49:14 +0000 Subject: convert all POST variables from display to unix charset (This used to be commit cd6478ad9890949d0ef34a7078ec5518debe4a3c) --- source3/web/cgi.c | 50 ++++++++++++++++++++++++++++---------------------- source3/web/swat.c | 2 +- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/source3/web/cgi.c b/source3/web/cgi.c index a8af9b2722..0227cd07a6 100644 --- a/source3/web/cgi.c +++ b/source3/web/cgi.c @@ -127,12 +127,12 @@ static char *grab_line(FILE *f, int *cl) with the same name and the same or different values. Takes a file parameter for simulating CGI invocation eg loading saved preferences. ***************************************************************************/ -void cgi_load_variables(FILE *f1) +void cgi_load_variables(void) { - FILE *f = f1; static char *line; char *p, *s, *tok; - int len; + int len, i; + FILE *f = stdin; #ifdef DEBUG_COMMENTS char dummy[100]=""; @@ -140,23 +140,16 @@ void cgi_load_variables(FILE *f1) printf("\n",__FILE__); #endif - if (!f1) { - f = stdin; - if (!content_length) { - p = getenv("CONTENT_LENGTH"); - len = p?atoi(p):0; - } else { - len = content_length; - } + if (!content_length) { + p = getenv("CONTENT_LENGTH"); + len = p?atoi(p):0; } else { - struct stat st; - fstat(fileno(f), &st); - len = st.st_size; + len = content_length; } if (len > 0 && - (f1 || request_post || + (request_post || ((s=getenv("REQUEST_METHOD")) && strcasecmp(s,"POST")==0))) { while (len && (line=grab_line(f, &len))) { @@ -188,13 +181,6 @@ void cgi_load_variables(FILE *f1) } } - if (f1) { -#ifdef DEBUG_COMMENTS - printf("\n"); -#endif - return; - } - fclose(stdin); open("/dev/null", O_RDWR); @@ -228,6 +214,26 @@ void cgi_load_variables(FILE *f1) #ifdef DEBUG_COMMENTS printf("\n"); #endif + + /* variables from the client are in display charset - convert them + to our internal charset before use */ + for (i=0;i