From d409355f62a183902e6f2ef7ba4380dfe85d2b10 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Sat, 1 Oct 2011 19:01:58 -0500 Subject: [PATCH] Recovering from RGBT-command (ref #577) --- pdf.js | 14 ++++++++++++++ test/pdfs/vesta.pdf.link | 1 + test/test_manifest.json | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 test/pdfs/vesta.pdf.link diff --git a/pdf.js b/pdf.js index 3fa22496a..cd643e760 100644 --- a/pdf.js +++ b/pdf.js @@ -4366,6 +4366,20 @@ var PartialEvaluator = (function partialEvaluator() { if (isCmd(obj)) { var cmd = obj.cmd; var fn = OP_MAP[cmd]; + if (!fn) { + // invalid content command, trying to recover + if (cmd.substr(-2) == 'BT') { + fn = OP_MAP[cmd.substr(0, cmd.length - 2)]; + // feeding 'BT' on next interation + parser = { + getObj: function() { + parser = this.oldParser; + return { name: 'BT' }; + }, + oldParser: parser + }; + } + } assertWellFormed(fn, "Unknown command '" + cmd + "'"); // TODO figure out how to type-check vararg functions diff --git a/test/pdfs/vesta.pdf.link b/test/pdfs/vesta.pdf.link new file mode 100644 index 000000000..7aa348dff --- /dev/null +++ b/test/pdfs/vesta.pdf.link @@ -0,0 +1 @@ +http://www-csag.ucsd.edu/~jburke/Vesta/Vesta_Overview.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 71738f192..51428190d 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -158,6 +158,12 @@ "rounds": 1, "type": "load" }, + { "id": "vesta-bad", + "file": "pdfs/vesta.pdf", + "link": true, + "rounds": 1, + "type": "load" + }, { "id": "ibwa-bad", "file": "pdfs/ibwa-bad.pdf", "link": true,