Bug 63862 - poppler generates bad postscript when PDF document title contains newline
Summary: poppler generates bad postscript when PDF document title contains newline
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-24 04:48 UTC by duncan
Modified: 2013-05-16 19:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
GZIPed tar file containing PDF with newline in name and PS output produced when viewing file with okular (51.33 KB, application/octet-stream)
2013-04-25 23:41 UTC, duncan
Details

Description duncan 2013-04-24 04:48:37 UTC
This bug was actually noticed when using okular (0.14.3) to view a file that had a "\r\n" sequence in it's name (don't ask!) and requesting that the document be printed to a postscript printer or saved as a postscript file.  The version of poppler installed here is currently 0.20.5, but from a quick look at the sources the same issue is present in 0.22.3.

Okular uses poppler to convert the document to postscript before printing or saving, and the resulting postscript file contains a "%%Title" line which has the name of the file in it.  The postscript file is therefore syntactically incorrect as the part of the file name following the "\r\n" occurs at the start of a line with no preceding comment character.

Arguably the fault is with okular, but it's possible that other applications using poppler could trigger the same issue and so a fix in poppler seems to me to be the best option.

I propose sanitising the contents of psTitle immediately before the call to writePSFmt() in

  if(psTitle) {
    writePSFmt("%%Title: {0:s}\n", psTitle);
  }

at line 1416 of poppler/PSOutputDev.cc.

Apologies for not including a tested patch, but my C++ is not strong, so I'm not sure if code using the standard C function index() (or perhaps strspn() or similar) is the appropriate way to fix this.  Also, our current environment is in the process of upgrading from poppler 0.20.5 to 0.22.3 and right now it would be awkward to attempt to build either the older or new version!  If no one comes up with a response to this before our environment has the new version installed I will attempt to do so...

Duncan
Comment 1 Albert Astals Cid 2013-04-24 07:11:49 UTC
Can you please attach such a file?
Comment 2 duncan 2013-04-25 23:41:03 UTC
Created attachment 78492 [details]
GZIPed tar file containing PDF with newline in name and PS output produced when viewing file with okular
Comment 3 Albert Astals Cid 2013-05-16 19:28:03 UTC
Will be fixed in next poppler 0.22.x release


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.