|
From: | Ikumi Keita |
Subject: | Re: [AUCTeX-devel] [gs-devel] Asking help for preview-latex |
Date: | Fri, 21 Jun 2019 00:06:08 +0900 |
Hi Ken, thank you for your reply. >>>>> Ken Sharp <address@hidden> writes: > Hi Keita, > (or should that be Ikumi ? Please accept an apology if I'm wrong) No problem, call me by whichever name you like. My given name is Keita and the family name is Ikumi, but I don't care in English conversation. > At 18:47 20/06/2019 +0900, Ikumi Keita wrote: > So essentially what you are saying is that you want the rendered > result of the PDF file to be in some colour other than the colour > which it should be. > For example, if the PDF file uses black, and the Emacs current colour > is (eg) green, then you want the PDF rendered as green. That's right. > So I'm going to assume this is some highly limited application of PDF > and Ghostscript where you can guarantee that the PDF file only uses > the default colour space and colour and never sets any other colours. Thanks for summarising, it looks sensible to me. > That started us down a long road of hardening the PostScript and PDF > interpreters to prevent any recurrence. Its quite clear that > permitting unfettered access to the PDF interpreter allowed malicious > software to bypass the security in Ghostscript with varying degrees of > ease. Obviously we don't want to undo any of that work and expose > ourselves to potential vulnerabilities again. I see. I understand the importance of security concerns. > In order to investigate properly I need a file that I can run through > Ghostscript, and a Ghostscript command line which will show the > difference with and without the code above. I can probably invent a > command line, but not the PDF file. The files involved are attached with this message. Let me explain how these files are processed by preview-latex. (0) The user types some key sequence in Emacs buffer of prv-tst.tex to enable preview-latex. The rest of the procedure are automated, and the user does not have to intervene. (1) First, preview-latex invokes pdflatex with the following command to generate tst-prv.pdf: pdflatex -file-line-error "\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}" "\input" "{\detokenize{" tst-prv.tex "}}" (2) Then, preview-latex invokes pdf2dsc with the following command: pdf2dsc tst-prv.pdf tst-prv.prv/tmp3GpVbI/preview.dsc The 3rd argument specifies a DSC file generated by preview-latex and saved in a temporal directory. The content of the DSC file is attached with this message as well. (3) Next, preview-latex invokes gs binary with the following command. "rungs" is just a wrapper for gs binary and equivalent to plain gs: /usr/local/texlive/2019/bin/amd64-freebsd/rungs -dOutputFile\=\(tst-prv.prv/tmp3GpVbI/pr1-\%d.png\) -q -dDELAYSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r108.606x108.587 If I understand correctly, this command lets gs to show a prompt "GS>" and wait for subsequent input. Preview-latex provides the following inputs to the prompt inside Emacs: {<</PermitFileReading[(tst-prv.pdf)(tst-prv.prv/tmp3GpVbI/preview.dsc)]>> setuserparams .locksafe} stopped pop {DELAYSAFER{.setsafe}if}stopped pop/.preview-BP currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1 ne or{.preview-BP 0.0937514 0.101564 0.14844 setrgbcolor clippath fill 0.8 0.8 0.8 setrgbcolor}{pop}ifelse}bind/PageSize[1 1]>>setpagedevice/preview-do{/.preview-ST[count 4 roll save]def dup length 0 eq{pop}{setpagedevice}{ifelse exec}stopped{handleerror quit}if .preview-ST aload pop restore}bind def /GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin/graphicsbeginpage{//graphicsbeginpage exec 0.8 0.8 0.8 3 copy rg RG}bind store end readonly store (tst-prv.prv/tmp3GpVbI/preview.dsc)(r)file /.preview-ST 1 index def dup 0 setfileposition 415()/SubFileDecode filter cvx exec .preview-ST dup dup 415 setfileposition 53()/SubFileDecode filter cvx<<>>preview-do (4) Then gs stops with this error message: Error: /undefined in GS_PDF_ProcSet Operand stack: GS_PDF_ProcSet Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- %loop_continue --nostringval-- --nostringval-- false 1 %stopped_push .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- Dictionary stack: --dict:739/1123(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)-- Current allocation mode is local Last OS error: No such file or directory Current file position is 627 GS<1> > I believe that if you send me a PDF file which shows a difference, > and the values substituted by the line '(mapconcat > #'preview-gs-color-value fg " ")' above, I can probably simply render > the file with and without that code to see what difference it makes. The PDF files are just the same, with no difference. The only difference is in the Postscript code given at the procedure (3) above. When Emacs have just standard foreground color, preview-latex omits the following part and the rests are the same: /GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin/graphicsbeginpage{//graphicsbeginpage exec 0.8 0.8 0.8 3 copy rg RG}bind store end readonly store I hope these information are of help for your analysis. Best regards, Ikumi Keita
tst-prv.tex
Description: sample LaTeX file
tst-prv.pdf
Description: sample PDF file
preview.dsc
Description: sample DSC file
prev001.png
Description: generated PNG file
[Prev in Thread] | Current Thread | [Next in Thread] |