From 50ff2d4c2afdd9f26e54ce77b3af6f651154467a Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Wed, 21 Oct 2015 15:39:25 +0200 Subject: [PATCH] Ignore operators that are known to be unsupported `operatorList.addOp` adds the arguments to the list which is then passed as-is by postMessage to the main thread. But since we don't parse these operations, they are raw PDF objects and may therefore cause a serialization error. This is a conservative patch, and only affects operators which are known to be unsupported. We should ignore all unknown operators, but I haven't really looked into the consequences of doing that. Fixes #6549 --- src/core/evaluator.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 453bd05f3..0594dd4d7 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -870,6 +870,24 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { case OPS.rectangle: self.buildPath(operatorList, fn, args); continue; + case OPS.markPoint: + case OPS.markPointProps: + case OPS.beginMarkedContent: + case OPS.beginMarkedContentProps: + case OPS.endMarkedContent: + case OPS.beginCompat: + case OPS.endCompat: + // Ignore operators where the corresponding handlers are known to + // be no-op in CanvasGraphics (display/canvas.js). This prevents + // serialization errors and is also a bit more efficient. + // We could also try to serialize all objects in a general way, + // e.g. as done in https://github.com/mozilla/pdf.js/pull/6266, + // but doing so is meaningless without knowing the semantics. + continue; + default: + // Note: Let's hope that the ignored operator does not have any + // non-serializable arguments, otherwise postMessage will throw + // "An object could not be cloned.". } operatorList.addOp(fn, args); }