Bug 40294 - Spaces in filenames make printing to pdf fail with error
Summary: Spaces in filenames make printing to pdf fail with error
Status: CLOSED FIXED
Alias: None
Product: kdeprint
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Goffioul
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-06 16:03 UTC by tosi
Modified: 2005-03-15 09:52 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tosi 2002-04-06 16:02:14 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kdeprint
Version:           KDE 3.0.0 
Severity:          normal
Installed from:    SuSE
Compiler:          gcc version 2.95.3 20010315 (SuSE)
OS:                Linux (i686) release 2.4.10-4GB
OS/Compiler notes: 

When printing an html page from konqueror to a pdf file the printong will fail if the printing module is fed with a filename that has spaces in its name.

This I tried ( to simulate a problem at a clients ):

* open up any webpage
* select print -> pdf
* filename = gögn.Greinar úr tímaritum/10 óskir um betra póstforrit ( CNET ).pdf

The printing fails.

A suggestion would be that spaces parenthesis and other characters that are actually valid in filenames would be escaped before calling ps2pdf and perhaps a scanner put in that grabs invalid characters and warns the user... ( such a scanner could of course be system-wide :-)

Thank you.


(Submitted via bugs.kde.org)
(Called from KBugReport dialog. Fields Application manually changed)
Comment 1 Michael Goffioul 2002-04-08 09:20:36 UTC
> When printing an html page from konqueror to a pdf file the printong will fail if the printing module is fed with a filename that has spaces in its name.
> 
> This I tried ( to simulate a problem at a clients ):
> 
> * open up any webpage
> * select print -> pdf
> * filename = gögn.Greinar úr tímaritum/10 óskir um betra póstforrit ( CNET ).pdf
> 
> The printing fails.
> 
> A suggestion would be that spaces parenthesis and other characters that are actually valid in filenames would be escaped before calling ps2pdf and perhaps a scanner put in that grabs invalid characters and warns the user... ( such a scanner could of course be system-wide :-)

The problem is not really KDEPrint but ps2pdf. KDEPrint does its job correctly and
quotes the output filename when calling ps2pdf. So theoretically you can use any
filename. However ps2pdf does not support white spaces in the filename. Indeed
on my distro program calls are as following:

ps2pdf -> ps2pdf12 -> ps2pdfwr -> gs

And when ps2pdfwr calls gs the filename is not quoted resulting in gs errors. So
the real solution is to patch ps2pdfwr to make it able to support white spaces in
filenames.

The only thing I could think about for KDEPrint is to warn the user about white
spaces in the output filename to tell him it may not work. But again KDEPrint does
things right (but then this would happen for any special printer).

Michael.

-- 
------------------------------------------------------------------
Michael GoffioulIMEC-DESICS-MIRA
e-mail: goffioul@imec.be(Mixed-Signal and RF Applications)
Tel:    +32/16/28-8510Kapeldreef 75
Fax:    +32/16/28-15153001 HEVERLEE BELGIUM
------------------------------------------------------------------
Comment 2 Michael Goffioul 2002-04-08 11:04:54 UTC
Modified the ps2pdf filter to be able to handle white spaces in filenames:
use "gs" directly instead of the ps2pdfxxx scripts.

-- 
------------------------------------------------------------------
Michael GoffioulIMEC-DESICS-MIRA
e-mail: goffioul@imec.be(Mixed-Signal and RF Applications)
Tel:    +32/16/28-8510Kapeldreef 75
Fax:    +32/16/28-15153001 HEVERLEE BELGIUM
------------------------------------------------------------------
Comment 3 Dietmar Hummel 2005-03-14 21:41:24 UTC
Hi!

I have nearly the same problem. I have an SO-document (which prints well through
kprintfax standalone). But if i add additional pdf-documents in kprintfax i get
an Usage: anytops ... Error.
I dont know who actually calls anytops but some debugging-comments in it gave me
the output that my original document "/data/sys/electronic documents/abc.pdf" got
interpreted as "/data/sys/electronic" for the input file. Therefore i think the
problem is not in pdf2ps but in calling anytops from kprintfax...

Thanks
Comment 4 Michael Goffioul 2005-03-15 09:52:46 UTC
CVS commit by goffioul: 

Properly quote anytops arguments.

CC-MAIL: 40294@bugs.kde.org


  M +2 -2      faxctrl.cpp   1.33


--- kdebase/kdeprint/kdeprintfax/faxctrl.cpp  #1.32:1.33
@@ -425,8 +425,8 @@ void FaxCtrl::filter()
                         m_tempfiles.append(tmp);
                         m_process->clearArguments();
-                        *m_process << locate("data","kdeprintfax/anytops") << "-m" << locate("data","kdeprintfax/faxfilters")
+                        *m_process << locate("data","kdeprintfax/anytops") << "-m" << KProcess::quote(locate("data","kdeprintfax/faxfilters"))
                                 << QString::fromLatin1("--mime=%1").arg(mimeType)
                                 << "-p" << pageSize()
-                                <<  m_files[0] << tmp;
+                                <<  KProcess::quote(m_files[0]) << KProcess::quote(tmp);
                         if (!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput))
                                 emit faxSent(false);