Index: kgv_miniwidget.cpp
===================================================================
RCS file: /home/kde/kdegraphics/kghostview/kgv_miniwidget.cpp,v
retrieving revision 1.100.2.3
diff -u -r1.100.2.3 kgv_miniwidget.cpp
--- kgv_miniwidget.cpp	27 Sep 2002 02:39:53 -0000	1.100.2.3
+++ kgv_miniwidget.cpp	6 Apr 2003 21:32:09 -0000
@@ -603,10 +603,16 @@
 {
     KProcess process;
     process << _interpreterPath
+	    << "-dSAFER"
+	    << "-dPARANOIDSAFER"
+	    << "-dDELAYSAFER"
 	    << "-dNODISPLAY" 
 	    << "-dQUIET" 
 	    << QString( "-sPDFname=%1" ).arg( pdfName )
 	    << QString( "-sDSCname=%1" ).arg( dscName )
+            << "-c"
+            << "<< /PermitFileReading [ PDFname ] /PermitFileWriting [ DSCname ] /PermitFileControl [] >> setuserparams .locksafe"
+            << "-f"
 	    << "pdf2dsc.ps"
 	    << "-c"
 	    << "quit";
@@ -968,7 +974,7 @@
 	    } 
 	
 	// Set 0 filename for gs -- use pipe.
-	page->setFileName( QString::null );
+	page->setFileName( format == PDF ? _pdfFileName : _fileName, true );
       
 	// finally set marked list
 	QString s, tip;
@@ -987,7 +993,7 @@
     else {
 	toc_length = 0;
 	toc_entry_length = 3;
-	page->setFileName( _fileName );
+	page->setFileName( _fileName, false );
 	QString s("1");
 	_marklist->insertItem( s, 0 );
     }
@@ -1066,11 +1072,11 @@
 	}
 	
 	const char *cmd_convert_pdf = 
-		"%s -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -sOutputFile=%s -c save pop -f \"%s\"";
+		"%s -q -dNOPAUSE -dBATCH -dSAFER -dPARANOIDSAFER -sDEVICE=pswrite -sOutputFile=%s -c save pop -f %s";
 	QCString cmd;
 	cmd.sprintf( cmd_convert_pdf, _interpreterPath.local8Bit().data(),
 		QFile::encodeName( _tmpFromPDF->name() ).data(), 
-		QFile::encodeName( _pdfFileName ).data() );
+		QFile::encodeName( KShellProcess::quote(_pdfFileName) ).data() );
   
 	// TODO -- timeout/fail on this conversion (it can hang on a bad pdf)
 	// TODO -- use output from gs (leave out -q) to drive a progress bar
Index: kpswidget.cpp
===================================================================
RCS file: /home/kde/kdegraphics/kghostview/kpswidget.cpp,v
retrieving revision 1.66
diff -u -r1.66 kpswidget.cpp
--- kpswidget.cpp	29 May 2001 00:49:46 -0000	1.66
+++ kpswidget.cpp	6 Apr 2003 21:32:09 -0000
@@ -222,9 +222,10 @@
  * Sets the filename of the ghostscript input. Usually we use a pipe for
  * communication and no filename will be needed.
  */
-void KPSWidget::setFileName( const QString& fileName )
+void KPSWidget::setFileName( const QString& fileName, bool usePipe )
 {
     _fileName = fileName;
+    _usePipe = usePipe;
 }
 
 void KPSWidget::setOrientation( KGV::Orientation orientation )
@@ -488,9 +489,12 @@
 
     if( !intConfig->platformFonts() )
 	*_process << "-dNOPLATFONTS";
-    *_process << "-dNOPAUSE" << "-dQUIET" << "-dSAFER";
-    if( _fileName.isEmpty() )
-	*_process << "-";
+    *_process << "-dNOPAUSE" << "-dQUIET" << "-dSAFER" << "-dPARANOIDSAFER";
+    if( _usePipe )
+        *_process <<
+        // The following two lines are their to ensure that we are allowed to read _fileName
+        "-dDELAYSAFER" << "-sInputFile="+_fileName << "-c" <<
+        "<< /PermitFileReading [ InputFile ] /PermitFileWriting [] /PermitFileControl [] >> setuserparams .locksafe";
     else 
 	*_process << _fileName << "-c" << "quit";
 
@@ -517,8 +521,8 @@
 
     // Finally fire up the interpreter.
     kdDebug(4500) << "KPSWidget: starting interpreter" << endl;
-    if( _process->start( KProcess::NotifyOnExit, _fileName.isEmpty() 
-		? KProcess::All : KProcess::AllOutput ) ) {
+    if( _process->start( KProcess::NotifyOnExit, 
+    		_usePipe ? KProcess::All : KProcess::AllOutput ) ) {
 	_stdinReady = true;
 	_interpreterReady = false;
     }
Index: kpswidget.h
===================================================================
RCS file: /home/kde/kdegraphics/kghostview/kpswidget.h,v
retrieving revision 1.37
diff -u -r1.37 kpswidget.h
--- kpswidget.h	27 May 2001 11:50:52 -0000	1.37
+++ kpswidget.h	6 Apr 2003 21:32:09 -0000
@@ -73,7 +73,7 @@
     bool nextPage();
     bool sendPS( FILE* fp, const KGV::FileOffset&, bool close);
     
-    void setFileName( const QString& );
+    void setFileName( const QString&, bool usePipe );
 
     void setPageSize( const QSize& );
     QSize pageSize() const { return _pageSize; }
@@ -149,6 +149,7 @@
     KGV::Orientation _orientation;
     bool show_messages;
     QString _fileName;
+    bool _usePipe;
 
     bool _stdinReady;
     bool _interpreterBusy;