-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.40 2006/09/09 13:05:33 fabiankeil Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.43 2006/12/17 17:57:56 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
*
* Revisions :
* $Log: cgisimple.c,v $
+ * Revision 1.43 2006/12/17 17:57:56 fabiankeil
+ * - Added FEATURE_GRACEFUL_TERMINATION to the
+ * "conditional #defines" section
+ * - Escaped ampersands in generated HTML.
+ * - Renamed re-filter-filename to re-filter-filenames
+ *
+ * Revision 1.42 2006/11/21 15:43:12 fabiankeil
+ * Add special treatment for WIN32 to make sure
+ * cgi_send_user_manual opens the files in binary mode.
+ * Fixes BR 1600411 and unbreaks image delivery.
+ *
+ * Remove outdated comment.
+ *
+ * Revision 1.41 2006/10/09 19:18:28 roro
+ * Redirect http://p.p/user-manual (without trailing slash) to
+ * http://p.p/user-manual/ (with trailing slash), otherwise links will be broken.
+ *
* Revision 1.40 2006/09/09 13:05:33 fabiankeil
* Modified cgi_send_user_manual to serve binary
* content without destroying it first. Should also be
}
/* Open user-manual file */
+#ifdef WIN32
+ /*
+ * XXX: Do we support other operating systems that
+ * require special treatment to fopen in binary mode?
+ */
+ if (NULL == (fp = fopen(full_path, "rb")))
+#else
if (NULL == (fp = fopen(full_path, "r")))
+#endif /* def WIN32 */
{
log_error(LOG_LEVEL_ERROR, "Cannot open user-manual file %s: %E", full_path);
err = cgi_error_no_template(csp, rsp, full_path);
if (!fread(rsp->body, length, 1, fp))
{
/*
- * Why should this happen? If it does, we just log
- * it and serve what we got, most likely padded with garbage.
+ * This happens if we didn't fopen in binary mode.
+ * If it does, we just log it and serve what we got,
+ * most likely padded with garbage.
*/
log_error(LOG_LEVEL_ERROR, "Couldn't completely read user-manual file %s.", full_path);
}
fclose(fp);
free(full_path);
- /* Privoxy only gets it right for non-binary content. */
rsp->content_length = (int)length;
/* Guess correct Content-Type based on the filename's ending */
*
* Function : cgi_show_status
*
- * Description : CGI function that returns a a web page describing the
+ * Description : CGI function that returns a web page describing the
* current status of Privoxy.
*
* Parameters :
int local_urls_read;
int local_urls_rejected;
#endif /* ndef FEATURE_STATISTICS */
- struct file_list * fl;
- struct url_actions * b;
jb_err err = JB_ERR_OK;
struct map *exports;
s = strdup("");
for (i = 0; i < MAX_AF_FILES; i++)
{
- if (((fl = csp->actions_list[i]) != NULL) && ((b = fl->f) != NULL))
+ if (csp->actions_list[i] != NULL)
{
if (!err) err = string_append(&s, "<tr><td>");
if (!err) err = string_join(&s, html_encode(csp->actions_list[i]->filename));
- snprintf(buf, 100, "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&index=%d\">View</a>", i);
+ snprintf(buf, 100, "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&index=%d\">View</a>", i);
if (!err) err = string_append(&s, buf);
#ifdef FEATURE_CGI_EDIT_ACTIONS
s = strdup("");
for (i = 0; i < MAX_AF_FILES; i++)
{
- if (((fl = csp->rlist[i]) != NULL) && ((b = fl->f) != NULL))
+ if (csp->rlist[i] != NULL)
{
if (!err) err = string_append(&s, "<tr><td>");
if (!err) err = string_join(&s, html_encode(csp->rlist[i]->filename));
- snprintf(buf, 100, "</td><td class=\"buttons\"><a href=\"/show-status?file=filter&index=%d\">View</a>", i);
+ snprintf(buf, 100,
+ "</td><td class=\"buttons\"><a href=\"/show-status?file=filter&index=%d\">View</a>", i);
if (!err) err = string_append(&s, buf);
if (!err) err = string_append(&s, "</td></tr>\n");
}
}
if (*s != '\0')
{
- if (!err) err = map(exports, "re-filter-filename", 1, s, 0);
+ if (!err) err = map(exports, "re-filter-filenames", 1, s, 0);
}
else
{
- if (!err) err = map(exports, "re-filter-filename", 1, "<tr><td>None specified</td></tr>", 1);
+ if (!err) err = map(exports, "re-filter-filenames", 1, "<tr><td>None specified</td></tr>", 1);
if (!err) err = map_block_killer(exports, "have-filterfile");
}
/* FIXME: Hardcoded HTML! */
string_append(&matches, "<tr><th>In file: ");
string_join (&matches, html_encode(csp->config->actions_file_short[i]));
- snprintf(buf, 150, ".action <a class=\"cmd\" href=\"/show-status?file=actions&index=%d\">", i);
+ snprintf(buf, 150, ".action <a class=\"cmd\" href=\"/show-status?file=actions&index=%d\">", i);
string_append(&matches, buf);
string_append(&matches, "View</a>");
#ifdef FEATURE_CGI_EDIT_ACTIONS
if (!err) err = map(exports, "FORCE_PREFIX", 1, "(none - disabled)", 1);
#endif /* ndef FEATURE_FORCE_LOAD */
+#ifdef FEATURE_GRACEFUL_TERMINATION
+ if (!err) err = map_conditional(exports, "FEATURE_GRACEFUL_TERMINATION", 1);
+#else /* ifndef FEATURE_GRACEFUL_TERMINATION */
+ if (!err) err = map_conditional(exports, "FEATURE_GRACEFUL_TERMINATION", 0);
+#endif /* ndef FEATURE_GRACEFUL_TERMINATION */
+
#ifdef FEATURE_IMAGE_BLOCKING
if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
#else /* ifndef FEATURE_IMAGE_BLOCKING */