web/hosts/issues graph.py,1.4,1.5

Nick Lewycky <[email protected]>
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/web/hosts/issues
In directory purcel:/tmp/cvs-serv20479

Modified Files:
	graph.py 
Log Message:
Whitelist only certain possible output types.
Fix SVG output (dot now prints the <?xml> header and doctype itself.)


Index: graph.py
===================================================================
RCS file: /cvs/fresco/web/hosts/issues/graph.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- graph.py	23 Jan 2003 05:09:40 -0000	1.4
+++ graph.py	24 Jan 2003 15:33:19 -0000	1.5
@@ -132,6 +132,11 @@
             write_depend(file, type, id, type, depend)
             visit(type, depend, 0)
 
+if (not (output == 'png' or output == 'svg' or output == 'gif' or output == 'cmap' or output == 'mif' or output == 'ps' or output == 'ps2')):
+    print 'Status: 500 Internal Server Error\n'
+    print '<html><head><title>graph</title></head><body>Bad parameter to script.</body></html>'
+    sys.exit(0)
+
 db = open_db()
 (file, child_stdout) = os.popen2('dot -T'+output)
 write_header(file, type, id)
@@ -143,19 +148,17 @@
 
 if output == 'png':
     print 'Content-type: image/png\n'
+elif output == 'ps' or output == 'ps2':
+    print 'Content-type: application/postscript\n'
 elif output == 'svg':
     print 'Content-type: image/svg+xml\n'
-    print '<?xml version="1.0" standalone="yes"?>'
-    print '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"'
-    print '  "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">'
 elif output == 'mif':
     print 'Content-type: application/vnd.mif\n'
 elif output == 'gif':
     print 'Content-type: image/gif\n'
-# you aren't using these two as a CGI script are you?
-elif output == 'imap' or output == 'ismap' or output == 'cmap':
+elif output == 'cmap':
     print 'Content-type: text/html\n'
-    print '<?xml version="1.0"?>'
+    print '<?xml version="1.0" standalone="no"?>'
     print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
     print '<html xmlns="http://www.w3.org/1999/xhtml">'
     print '<head>'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.