#include "webcit.h"
#include "groupdav.h"
#include "webserver.h"
-#include "mime_parser.h"
#include <stdio.h>
#include <stdarg.h>
*/
static char *unset = "; expires=28-May-1971 18:10:00 GMT";
-/**
+/**
* \brief remove escaped strings from i.e. the url string (like %20 for blanks)
* \param buf the buffer to examine
*/
* \param nbsp If nonzero, spaces are converted to non-breaking spaces.
* \param nolinebreaks if set, linebreaks are removed from the string.
*/
-void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
+long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks)
{
- int a, len;
- strcpy(target, "");
+ char *aptr, *bptr, *eptr;
- len = strlen(strbuf);
- for (a = 0; a < len; ++a) {
- if (strbuf[a] == '<')
- strcat(target, "<");
- else if (strbuf[a] == '>')
- strcat(target, ">");
- else if (strbuf[a] == '&')
- strcat(target, "&");
- else if (strbuf[a] == '\"')
- strcat(target, """);
- else if (strbuf[a] == '\'')
- strcat(target, "'");
- else if (strbuf[a] == LB)
- strcat(target, "<");
- else if (strbuf[a] == RB)
- strcat(target, ">");
- else if (strbuf[a] == QU)
- strcat(target, "\"");
- else if ((strbuf[a] == 32) && (nbsp == 1))
- strcat(target, " ");
- else if ((strbuf[a] == '\n') && (nolinebreaks))
- strcat(target, ""); /* nothing */
- else if ((strbuf[a] == '\r') && (nolinebreaks))
- strcat(target, ""); /* nothing */
- else
- strncat(target, &strbuf[a], 1);
+ *target = '\0';
+ aptr = strbuf;
+ bptr = target;
+ eptr = target + tSize - 6; // our biggest unit to put in...
+
+ while ((bptr < eptr) && !IsEmptyStr(aptr) ){
+ if (*aptr == '<') {
+ memcpy(bptr, "<", 4);
+ bptr += 4;
+ }
+ else if (*aptr == '>') {
+ memcpy(bptr, ">", 4);
+ bptr += 4;
+ }
+ else if (*aptr == '&') {
+ memcpy(bptr, "&", 5);
+ bptr += 5;
+ }
+ else if (*aptr == '\"') {
+ memcpy(bptr, """, 6);
+ bptr += 6;
+ }
+ else if (*aptr == '\'') {
+ memcpy(bptr, "'", 5);
+ bptr += 5;
+ }
+ else if (*aptr == LB) {
+ *bptr = '<';
+ bptr ++;
+ }
+ else if (*aptr == RB) {
+ *bptr = '>';
+ bptr ++;
+ }
+ else if (*aptr == QU) {
+ *bptr ='"';
+ bptr ++;
+ }
+ else if ((*aptr == 32) && (nbsp == 1)) {
+ memcpy(bptr, " ", 6);
+ bptr += 6;
+ }
+ else if ((*aptr == '\n') && (nolinebreaks)) {
+ *bptr='\0'; /* nothing */
+ }
+ else if ((*aptr == '\r') && (nolinebreaks)) {
+ *bptr='\0'; /* nothing */
+ }
+ else{
+ *bptr = *aptr;
+ bptr++;
+ }
+ aptr ++;
}
+ *bptr = '\0';
+ if ((bptr = eptr - 1 ) && !IsEmptyStr(aptr) )
+ return -1;
+ return (bptr - target);
}
/**
void escputs1(char *strbuf, int nbsp, int nolinebreaks)
{
char *buf;
+ long Siz;
if (strbuf == NULL) return;
- buf = malloc( (3 * strlen(strbuf)) + SIZ );
- stresc(buf, strbuf, nbsp, nolinebreaks);
+ Siz = (3 * strlen(strbuf)) + SIZ ;
+ buf = malloc(Siz);
+ stresc(buf, Siz, strbuf, nbsp, nolinebreaks);
wprintf("%s", buf);
free(buf);
}
void urlesc(char *outbuf, char *strbuf)
{
int a, b, c, len, eclen, olen;
- char *ec = " #&;`'|*?-~<>^()[]{}/$\"\\";
+ char *ec = " +#&;`'|*?-~<>^()[]{}/$\"\\";
strcpy(outbuf, "");
len = strlen(strbuf);
outbuf = malloc( buflen);
outbuf2 = malloc( buflen);
msgesc(outbuf, strbuf);
- stresc(outbuf2, outbuf, 0, 0);
+ stresc(outbuf2, buflen, outbuf, 0, 0);
wprintf("%s", outbuf2);
free(outbuf);
free(outbuf2);
wprintf("Content-type: text/html; charset=utf-8\r\n"
"Server: %s / %s\n"
"Connection: close\r\n",
- SERVER, serv_info.serv_software
+ PACKAGE_STRING, serv_info.serv_software
);
}
"Server: %s\r\n"
"Connection: close\r\n",
content_type,
- SERVER);
+ PACKAGE_STRING);
#ifdef HAVE_ZLIB
/** If we can send the data out compressed, please do so. */
* Instead of an ugly 404, send a 1x1 transparent GIF
* when there's no such image on the server.
*/
- output_static("static/blank.gif");
+ char blank_gif[SIZ];
+ snprintf (blank_gif, SIZ, "%s%s", static_dirs[0], "/blank.gif");
+ output_static(blank_gif);
}
"Cache-Control: no-cache\r\n"
"Expires: -1\r\n"
,
- SERVER);
+ PACKAGE_STRING);
begin_burst();
}
wprintf("HTTP/1.1 404 Security check failed\r\n");
wprintf("Content-Type: text/plain\r\n");
wprintf("\r\n");
- wprintf("Security check failed.\r\n");
+ wprintf("You have sent a malformed or invalid request.\r\n");
}
goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
}
url_do_template();
} else if (!strcasecmp(action, "display_aide_menu")) {
display_aide_menu();
+ } else if (!strcasecmp(action, "server_shutdown")) {
+ display_shutdown();
} else if (!strcasecmp(action, "display_main_menu")) {
display_main_menu();
} else if (!strcasecmp(action, "who")) {
begin_ajax_response();
calendar_section();
end_ajax_response();
+ } else if (!strcasecmp(action, "mini_calendar")) {
+ begin_ajax_response();
+ ajax_mini_calendar();
+ end_ajax_response();
} else if (!strcasecmp(action, "iconbar_ajax_menu")) {
begin_ajax_response();
do_iconbar();
delete_node();
} else if (!strcasecmp(action, "display_add_node")) {
display_add_node();
- } else if (!strcasecmp(action, "add_node")) {
- add_node();
} else if (!strcasecmp(action, "terminate_session")) {
slrp_highest();
terminate_session();
display_sieve();
} else if (!strcasecmp(action, "save_sieve")) {
save_sieve();
+ } else if (!strcasecmp(action, "display_pushemail")) {
+ display_pushemail();
+ } else if (!strcasecmp(action, "save_pushemail")) {
+ save_pushemail();
} else if (!strcasecmp(action, "display_add_remove_scripts")) {
display_add_remove_scripts(NULL);
} else if (!strcasecmp(action, "create_script")) {
}
}
+/**
+ * \brief Replacement for sleep() that uses select() in order to avoid SIGALRM
+ * \param seconds how many seconds should we sleep?
+ */
+void sleeeeeeeeeep(int seconds)
+{
+ struct timeval tv;
+
+ tv.tv_sec = seconds;
+ tv.tv_usec = 0;
+ select(0, NULL, NULL, NULL, &tv);
+}
+
/*@}*/