1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Check isEvalSupported, and test that eval is actually supported, before attempting to use the PostScriptCompiler (issue 5573)

Currently `PDFFunction` is implemented (basically) like a class with only `static` methods. Since it's used directly in a number of different `src/core/` files, attempting to pass in `isEvalSupported` would result in code that's *very* messy, not to mention difficult to maintain (since *every* single `PDFFunction` method call would need to include a `isEvalSupported` argument).

Rather than having to wait for a possible re-factoring of `PDFFunction` that would avoid the above problems by design, it probably makes sense to at least set `isEvalSupported` globally for `PDFFunction`.

Please note that there's one caveat with this solution: If `PDFJS.getDocument` is used to open multiple files simultaneously, with *different* `PDFJS.isEvalSupported` values set before each call, then the last one will always win.
However, that seems like enough of an edge-case that we shouldn't have to worry about it. Besides, since we'll also test that `eval` is actually supported, it should be fine.

Fixes 5573.
This commit is contained in:
Jonas Jenwald 2017-09-14 15:38:57 +02:00
parent d0d7046129
commit dc926ffc0f
5 changed files with 32 additions and 9 deletions

View file

@ -24,6 +24,7 @@ import { OperatorList, PartialEvaluator } from './evaluator';
import { AnnotationFactory } from './annotation';
import { calculateMD5 } from './crypto';
import { Linearization } from './parser';
import { PDFFunction } from './function';
var Page = (function PageClosure() {
@ -532,6 +533,9 @@ var PDFDocument = (function PDFDocumentClosure() {
},
};
this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
let evaluatorOptions = this.pdfManager.evaluatorOptions;
PDFFunction.setIsEvalSupported(evaluatorOptions.isEvalSupported);
},
get numPages() {
var linearization = this.linearization;