From 714b375a58593b62a38c3fa5dfacd0fae2d7d1f9 Mon Sep 17 00:00:00 2001 From: Alex Cherepanov Date: Tue, 1 May 2012 12:29:03 -0400 Subject: Bug 693006: Guess malformed numbers. If an unknown PDF operator has only [-.0-9], consider it a malformed number and replace with 0. --- gs/Resource/Init/pdf_base.ps | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gs/Resource/Init/pdf_base.ps b/gs/Resource/Init/pdf_base.ps index 9edd0fab3..fc0d88639 100644 --- a/gs/Resource/Init/pdf_base.ps +++ b/gs/Resource/Init/pdf_base.ps @@ -98,6 +98,8 @@ pdfdict begin (#) search { name#escape } if concatstrings } bind def +/num-chars-dict mark (0123456789-.) {dup} forall .dicttomark readonly def + % Execute a file, interpreting its executable names in a given % dictionary. The name procedures may do whatever they want % to the operand stack. @@ -105,20 +107,32 @@ pdfdict begin BXlevel 0 le { ( **** Unknown operator: ') pdfformaterror dup =string cvs pdfformaterror + (') pdfformaterror % Attempt a retry scan of the element after changing to PDFScanInvNum << /PDFScanInvNum //true >> setuserparams =string cvs token pop exch pop dup type dup /integertype eq exch /realtype eq or { exch pop exch pop - (', processed as number, value: ) pdfformaterror + (, processed as number, value: ) pdfformaterror dup =string cvs pdfformaterror (\n) pdfformaterror << /PDFScanInvNum //null >> setuserparams % reset to default scanning rules //false % suppress any stack cleanup } { - % error was non-recoverable with modified scanning rules - ('\n) pdfformaterror - //true + % error was non-recoverable with modified scanning rules, continue. + dup type /nametype eq { + //true 1 index .namestring { + //num-chars-dict exch known and + } forall { % perhaps, it's a malformed number. + pop pop pop 0 //false + ( looks like a malformed number, replacing with 0.) pdfformaterror + } { + //true % punt + } ifelse + } { + //true % punt + } ifelse + (\n) pdfformaterror } ifelse } { //true @@ -127,6 +141,9 @@ pdfdict begin pop pop count exch sub { pop } repeat % pop all the operands } if } bind def + +currentdict /num-chars-dict .undef + /.pdfexectoken { % .pdfexectoken ? PDFDEBUG { pdfdict /PDFSTEPcount known not { pdfdict /PDFSTEPcount 1 .forceput } if -- cgit v1.2.3