Bug 15149 - embedFonts crashes on filenames with spaces
embedFonts crashes on filenames with spaces
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Graphics
R 2.15.1
Other Linux
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-19 19:29 UTC by Dan Keshet
Modified: 2012-12-25 17:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Keshet 2012-12-19 19:29:10 UTC
Running embedFonts on filenames with spaces results in an error, because the filename isn't escaped or quoted in the internal call to ghostscript.

Steps to reproduce:

1) Run embedFonts on a filename with spaces.

Actual results:

* Error is raised

Expected Results:

fonts embedded.

> embedFonts(file='../output/Two words/example.pdf')
Error: /undefinedfilename in (../output/Two)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:1168/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.06: Unrecoverable error, exit code 1
Error in embedFonts(file = "../output/Two words/example.pdf") : 
  status 1 in running command 'gs -dNOPAUSE -dBATCH -q -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=/tmp/Rtmpu7SL0u/Rembed93237016e29 -sFONTPATH=  ../output/Two words/example.pdf'

Enter a frame number, or 0 to exit   

1: embedFonts(file = "../output/Two words/example.pdf")
Comment 1 Brian Ripley 2012-12-25 09:42:44 UTC
It does not 'crash': see the R posting guide for the proper use of that word.

The short answr is 'don't do that' (on Linux: why?).  But shQuote() has been added.
Comment 2 Dan Keshet 2012-12-25 17:50:22 UTC
(In reply to comment #1)
> The short answr is 'don't do that' (on Linux: why?).  

There's a few reasons: 

1) I have a cross-platform development team and the developers on non-linux OSes prefer names with spaces.  As it works for them, they will have a hard time remembering not to use them.

2) Many of our filenames are generated automatically based on data structures, whose names are in turn imported from our data sources.  We like to keep the original names around so that they appear in a friendly way as graph labels; maintaining separate names for filenames and graph labels is certainly possible, but its unnecessary overhead except for this one call (before your fix).

> But shQuote() has been added.

Thank you!