pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp doc/configuring.texi src/output/ChangeLog ...


From: Ben Pfaff
Subject: [Pspp-cvs] pspp doc/configuring.texi src/output/ChangeLog ...
Date: Mon, 03 Jul 2006 17:39:07 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Changes by:     Ben Pfaff <blp> 06/07/03 17:39:07

Modified files:
        doc            : configuring.texi 
        src/output     : ChangeLog html.c htmlP.h 

Log message:
        Make the destination for charts configurable in the HTML driver.
        Fixes bug #15723, "HTML driver creates .png files insecurely".
        Thanks to John Darrington for review.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/configuring.texi?cvsroot=pspp&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/ChangeLog?cvsroot=pspp&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/html.c?cvsroot=pspp&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/htmlP.h?cvsroot=pspp&r1=1.5&r2=1.6

Patches:
Index: doc/configuring.texi
===================================================================
RCS file: /cvsroot/pspp/pspp/doc/configuring.texi,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- doc/configuring.texi        17 Apr 2006 02:13:12 -0000      1.8
+++ doc/configuring.texi        3 Jul 2006 17:39:07 -0000       1.9
@@ -797,14 +797,19 @@
 is very simple.  Currently, the output has a very plain format.  In the
 future, further work may be done on improving the output appearance.
 
-There are is only one option:
+There are only a few options:
 
 @table @code
 @item address@hidden
 
 File to which output should be sent.  This can be an ordinary file name
 (i.e., @code{"pspp.ps"}), a pipe (i.e., @code{"|lpr"}), or
-stdout (@code{"-"}).  Default: @code{"pspp.html"}.
+stdout (@code{"-"}).  Default: @file{"pspp.html"}.
+
address@hidden address@hidden
+Template for the file names used for charts, which are output in PNG
+format.  The name should contain a single @samp{#}, which is replaced by
+the chart number.  Default: @file{"pspp-#.png"}.
 @end table
 
 @node Miscellaneous configuring,, HTML driver class, Configuration

Index: src/output/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/ChangeLog,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- src/output/ChangeLog        2 Jul 2006 05:44:25 -0000       1.12
+++ src/output/ChangeLog        3 Jul 2006 17:39:07 -0000       1.13
@@ -1,3 +1,16 @@
+Sat Jul  1 17:20:03 2006  Ben Pfaff  <address@hidden>
+
+       Make the destination for charts configurable in the HTML driver.
+       Fixes bug #15723, "HTML driver creates .png files insecurely".
+
+       * htmlP.h: (struct html_driver_ext) Add chart_file_name, chart_cnt
+       members.
+       
+       * html.c: (html_open_driver) Initialize new members.
+       (option_tab var) Add "chart-files" option.
+       (handle_option) Parse "chart-files" option.
+       (html_initialise_chart) Name file based on "chart-files" option.
+       
 Sat Jul  1 22:41:26 2006  Ben Pfaff  <address@hidden>
 
        Fix bug #16644: Output Driver crashes in DISPLAY VARIABLES.

Index: src/output/html.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/html.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- src/output/html.c   9 Jun 2006 22:51:24 -0000       1.11
+++ src/output/html.c   3 Jul 2006 17:39:07 -0000       1.12
@@ -36,7 +36,8 @@
 #include "manager.h"
 #include "table.h"
 #include <libpspp/version.h>
-#include <data/make-file.h>
+
+#include "size_max.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -56,7 +57,9 @@
 
   this->ext = x = xmalloc (sizeof *x);
   x->file_name = xstrdup ("pspp.html");
+  x->chart_file_name = xstrdup ("pspp-#.png");
   x->file = NULL;
+  x->chart_cnt = 0;
 
   outp_parse_options (options, handle_option, this);
 
@@ -146,6 +149,7 @@
 static struct outp_option option_tab[] =
   {
     {"output-file",            string_arg,     0},
+    {"chart-files",            string_arg,     1},
     {NULL, 0, 0},
   };
 
@@ -164,9 +168,24 @@
              key);
       break;
     case string_arg:
+      switch (subcat) 
+        {
+        case 0:
       free (x->file_name);
       x->file_name = ds_xstrdup (val);
       break;
+        case 1:
+          if (ds_find_char (val, '#') != SIZE_MAX) 
+            {
+              free (x->chart_file_name);
+              x->chart_file_name = ds_xstrdup (val);
+            }
+          error (0, 0, _("`chart-files' value must contain `#'"));
+          break;
+        default:
+          abort ();
+        }
+      break;
     default:
       abort ();
     }
@@ -339,20 +358,35 @@
 }
 
 static void
-html_initialise_chart(struct outp_driver *d UNUSED, struct chart *ch)
+html_initialise_chart (struct outp_driver *this, struct chart *ch)
 {
+#ifdef NO_CHARTS
+  ch->lp = NULL;
+#else
+  struct html_driver_ext *x = this->ext;
 
   FILE  *fp;
+  int number_pos;
 
-  make_unique_file_stream(&fp, &ch->file_name);
+  x->chart_cnt++;
 
-#ifdef NO_CHARTS
-  ch->lp = 0;
-#else
-  ch->pl_params = pl_newplparams();
+  number_pos = strchr (x->chart_file_name, '#') - x->chart_file_name;
+  ch->file_name = xasprintf ("%.*s%d%s",
+                             number_pos, x->chart_file_name,
+                             x->chart_cnt,
+                             x->chart_file_name + number_pos + 1);
+  fp = fopen (ch->file_name, "wb");
+  if (fp == NULL) 
+    {
+      error (0, errno, _("creating \"%s\""), ch->file_name);
+      free (ch->file_name);
+      ch->file_name = NULL;
+      return;
+    }
+
+  ch->pl_params = pl_newplparams ();
   ch->lp = pl_newpl_r ("png", 0, fp, stderr, ch->pl_params);
 #endif
-
 }
 
 static void 

Index: src/output/htmlP.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/htmlP.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- src/output/htmlP.h  9 Jun 2006 22:51:24 -0000       1.5
+++ src/output/htmlP.h  3 Jul 2006 17:39:07 -0000       1.6
@@ -26,7 +26,10 @@
 struct html_driver_ext
   {
     char *file_name;
+    char *chart_file_name;
     FILE *file;
+
+    size_t chart_cnt;
   };
 
 extern struct outp_class html_class;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]