/*
cgitest.c - Testprogram for cgi.o
- Copyright (c) 1998,9 by Martin Schulze <joey@infodrom.org>
+ Copyright (c) 1998,9,1007 by Martin Schulze <joey@infodrom.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
{
char **vars;
char *val;
+ char *tmp;
s_cookie *cookie;
int i;
printf ("<h3>Environment Variables</h3>\n<pre>\n");
- for (i=0; env[i]; i++)
- printf ("%s\n", env[i]);
+ for (i=0; env[i]; i++) {
+ tmp = cgiEscape (env[i]);
+ if (tmp) {
+ printf ("%s\n", tmp);
+ free (tmp);
+ }
+ }
printf ("</pre>\n<h3>CGI Variables</h3>\n<pre>\n");
if (vars) {
for (i=0; vars[i] != NULL; i++) {
val = cgiGetValue (cgi, vars[i]);
- printf ("%s=%s\n", vars[i], val?val:"");
+ if (val) {
+ tmp = cgiEscape (val);
+ if (tmp) {
+ printf ("%s=%s\n", vars[i], tmp);
+ free (tmp);
+ } else
+ printf ("%s=...\n", vars[i]);
+ } else
+ printf ("%s=\n", vars[i]);
}
for (i=0; vars[i] != NULL; i++)
free (vars[i]);
if (vars) {
for (i=0; vars[i] != NULL; i++) {
cookie = cgiGetCookie (cgi, vars[i]);
- printf ("%s=%s\n", vars[i], cookie?cookie->value:"");
+ if (cookie) {
+ tmp = cgiEscape (cookie->value);
+ if (tmp) {
+ printf ("%s=%s\n", vars[i], tmp);
+ free (tmp);
+ } else
+ printf ("%s=...\n", vars[i]);
+ } else
+ printf ("%s=\n", vars[i]);
}
for (i=0; vars[i] != NULL; i++)
free (vars[i]);