diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c --- a/usr.sbin/cron/cron/do_command.c +++ b/usr.sbin/cron/cron/do_command.c @@ -84,6 +84,20 @@ Debug(DPROC, ("[%d] main process returning to work\n", getpid())) } +static char* escape_html(int ch, char* tempbuf) { + + switch (ch) { + case '<': + return "<"; + case '>': + return ">"; + case '&': + return "&"; + default: + tempbuf[0] = ch; + return tempbuf; + } +} static void child_process(e, u) @@ -524,7 +538,10 @@ for (env = e->envp; *env; env++) fprintf(mail, "X-Cron-Env: <%s>\n", *env); + + fprintf(mail, "Content-Type: text/html\n"); fprintf(mail, "\n"); + fprintf(mail, "
\n"); /* this was the first char from the pipe */ @@ -538,8 +555,15 @@ while (EOF != (ch = getc(in))) { bytes++; - if (mail) - putc(ch, mail); + if (mail) { + char tempbuf[2] = {0, 0}; + char* escapedstring = escape_html(ch, &tempbuf[0]); + fputs(escapedstring, mail); + } + } + + if (mailto) { + fprintf(mail, "\n"); } } /*if data from grandchild*/