inactive actions are listed separately. Patch provided by Lee.
- The GNUmakefile supports the DESTDIR variable. Patch for
the install target submitted by Radoslaw Zielinski.
+- Embedding the content of configuration files in the show-status
+ page is significantly faster now. For a largish action file (1 MB)
+ a speedup of about 2450 times has been measured. This is mostly
+ interesting if you are using large action files or regularly use
+ Privoxy-Regression-Test while running Privoxy through Valgrind,
+ for stock configuration files it doesn't really matter.
- The obsolete kill-popups action has been removed as the
PCRS-based popup filters can do the same and are less
unreliable.
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.68 2008/03/27 18:27:21 fabiankeil Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.69 2008/04/17 14:40:48 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
*
* Revisions :
* $Log: cgisimple.c,v $
+ * Revision 1.69 2008/04/17 14:40:48 fabiankeil
+ * Provide get_http_time() with the buffer size so it doesn't
+ * have to blindly assume that the buffer is big enough.
+ *
* Revision 1.68 2008/03/27 18:27:21 fabiankeil
* Remove kill-popups action.
*
return JB_ERR_MEMORY;
}
- if ((fp = fopen(filename, "r")) == NULL)
+ if ((fp = fopen(filename, "rb")) == NULL)
{
if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
{
}
else
{
- s = strdup("");
- while ((s != NULL) && fgets(buf, sizeof(buf), fp))
+ /*
+ * XXX: this code is "quite similar" to the one
+ * in cgi_send_user_manual() and should be refactored.
+ * While at it, the return codes for ftell() and fseek
+ * should be verified.
+ */
+ size_t length;
+ /* Get file length */
+ fseek(fp, 0, SEEK_END);
+ length = (size_t)ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ s = (char *)zalloc(length+1);
+ if (NULL == s)
+ {
+ fclose(fp);
+ return JB_ERR_MEMORY;
+ }
+ if (!fread(s, length, 1, fp))
{
- string_join (&s, html_encode(buf));
+ /*
+ * May happen if the file size changes between fseek() and fread().
+ * If it does, we just log it and serve what we got.
+ */
+ log_error(LOG_LEVEL_ERROR, "Couldn't completely read file %s.", filename);
}
fclose(fp);
+ s = html_encode_and_free_original(s);
+ if (NULL == s)
+ {
+ return JB_ERR_MEMORY;
+ }
+
if (map(exports, "contents", 1, s, 0))
{
free_map(exports);