summaryrefslogtreecommitdiff
path: root/source3/web
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-09-24 04:49:14 +0000
committerAndrew Tridgell <tridge@samba.org>2001-09-24 04:49:14 +0000
commit1fcc9e1f6d2a6ee3f170055692cbfbe7432cf7ee (patch)
tree4d4a69fe60b90f948fe8189ffbe39d38993ab78c /source3/web
parentfee958d31a949fa1ef4452f43a98b7edecbd8cd8 (diff)
downloadsamba-1fcc9e1f6d2a6ee3f170055692cbfbe7432cf7ee.tar.gz
samba-1fcc9e1f6d2a6ee3f170055692cbfbe7432cf7ee.tar.bz2
samba-1fcc9e1f6d2a6ee3f170055692cbfbe7432cf7ee.zip
convert all POST variables from display to unix charset
(This used to be commit cd6478ad9890949d0ef34a7078ec5518debe4a3c)
Diffstat (limited to 'source3/web')
-rw-r--r--source3/web/cgi.c50
-rw-r--r--source3/web/swat.c2
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("<!== Start dump in cgi_load_variables() %s ==>\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("<!== End dump in cgi_load_variables() ==>\n");
-#endif
- return;
- }
-
fclose(stdin);
open("/dev/null", O_RDWR);
@@ -228,6 +214,26 @@ void cgi_load_variables(FILE *f1)
#ifdef DEBUG_COMMENTS
printf("<!== End dump in cgi_load_variables() ==>\n");
#endif
+
+ /* variables from the client are in display charset - convert them
+ to our internal charset before use */
+ for (i=0;i<num_variables;i++) {
+ pstring dest;
+
+ convert_string(CH_DISPLAY, CH_UNIX,
+ variables[i].name, -1,
+ dest, sizeof(dest));
+ free(variables[i].name);
+ variables[i].name = strdup(dest);
+
+ convert_string(CH_DISPLAY, CH_UNIX,
+ variables[i].value, -1,
+ dest, sizeof(dest));
+ free(variables[i].value);
+ variables[i].value = strdup(dest);
+ }
+
+
}
diff --git a/source3/web/swat.c b/source3/web/swat.c
index 56ce321f8d..9a7658e94f 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -1042,7 +1042,7 @@ static void printers_page(void)
print_header();
- cgi_load_variables(NULL);
+ cgi_load_variables();
if (!file_exist(servicesf, NULL)) {
have_read_access = True;