diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..761f05276 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.pdf -crlf diff --git a/src/core/obj.js b/src/core/obj.js index afe53838a..996a91007 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -758,6 +758,9 @@ var XRef = (function XRefClosure() { if (ch === 37) { // %-comment do { ++position; + if (position >= length) { + break; + } ch = buffer[position]; } while (ch !== 13 && ch !== 10); continue; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 630c94902..8463dee42 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -36,6 +36,7 @@ !type4psfunc.pdf !issue1350.pdf !S2.pdf +!helloworld-bad.pdf !zerowidthline.pdf !issue1002.pdf !issue925.pdf diff --git a/test/pdfs/helloworld-bad.pdf b/test/pdfs/helloworld-bad.pdf new file mode 100644 index 000000000..9e1706643 --- /dev/null +++ b/test/pdfs/helloworld-bad.pdf @@ -0,0 +1,68 @@ +%PDF-1.7 + +1 0 obj % entry point +<< + /Type /Catalog + /Pages 2 0 R +>> +endobj + +2 0 obj +<< + /Type /Pages + /MediaBox [ 0 0 200 200 ] + /Count 1 + /Kids [ 3 0 R ] +>> +endobj + +3 0 obj +<< + /Type /Page + /Parent 2 0 R + /Resources << + /Font << + /F1 4 0 R + >> + >> + /Contents 5 0 R +>> +endobj + +4 0 obj +<< + /Type /Font + /Subtype /Type1 + /BaseFont /Times-Roman +>> +endobj + +5 0 obj % page content +<< + /Length 44 +>> +stream +BT +70 50 TD +/F1 12 Tf +(Hello, world!) Tj +ET +endstream +endobj + +xref +0 6 +0000000000 65535 f +0000000010 00000 n +0000000079 00000 n +0000000173 00000 n +0000000301 00000 n +0000000380 00000 n +trailer +<< + /Size 6 + /Root 1 0 R +>> +startxref +492 +%%EOF \ No newline at end of file diff --git a/test/test_manifest.json b/test/test_manifest.json index 18b5f3024..0ddd358cc 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -897,6 +897,12 @@ "link": true, "type": "eq" }, + { "id": "helloworld-bad", + "file": "pdfs/helloworld-bad.pdf", + "md5": "bf5ab1cf7fe3a502c3754f55e6ceeabd", + "rounds": 1, + "type": "load" + }, { "id": "issue818", "file": "pdfs/issue818.pdf", "md5": "dd2f8a5bd65164ad74da2b45a6ca90cc",