aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-08-11 01:37:05 +0200
committerJay Berkenbilt <ejb@ql.org>2017-08-11 03:30:32 +0200
commit30f109e244f365111d5219903f13d64cf1a95054 (patch)
tree0bb3bca1f13bc8a2e3d0afa57bd96f3f06cc084c /qpdf
parent98a843c2a2e09df6457c023a8da52faa0d977a12 (diff)
downloadqpdf-30f109e244f365111d5219903f13d64cf1a95054.tar.zst
Read xref table without PCRE
Also accept more errors than before.
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qpdf.testcov4
-rw-r--r--qpdf/qtest/qpdf.test9
-rw-r--r--qpdf/qtest/qpdf/xref-errors.out15
-rw-r--r--qpdf/qtest/qpdf/xref-errors.pdf79
4 files changed, 106 insertions, 1 deletions
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov
index 2860f55e..c08ed721 100644
--- a/qpdf/qpdf.testcov
+++ b/qpdf/qpdf.testcov
@@ -289,3 +289,7 @@ qpdf single-pages %d 0
qpdf single-pages .pdf 0
qpdf single-pages other 0
QPDFTokenizer allowing bad token 0
+QPDF ignore first space in xref entry 0
+QPDF ignore first extra space in xref entry 0
+QPDF ignore second extra space in xref entry 0
+QPDF ignore length error xref entry 0
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index b3d13bde..d0cba589 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -232,7 +232,7 @@ foreach my $d (@bug_tests)
show_ntests();
# ----------
$td->notify("--- Miscellaneous Tests ---");
-$n_tests += 86;
+$n_tests += 87;
$td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"},
@@ -669,6 +669,13 @@ $td->runtest("ignore bad token",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
+$td->runtest("recoverable xref errors",
+ {$td->COMMAND =>
+ "qpdf --check --show-xref xref-errors.pdf"},
+ {$td->FILE => "xref-errors.out",
+ $td->EXIT_STATUS => 3},
+ $td->NORMALIZE_NEWLINES);
+
show_ntests();
# ----------
$td->notify("--- Single Page ---");
diff --git a/qpdf/qtest/qpdf/xref-errors.out b/qpdf/qtest/qpdf/xref-errors.out
new file mode 100644
index 00000000..7a2cf384
--- /dev/null
+++ b/qpdf/qtest/qpdf/xref-errors.out
@@ -0,0 +1,15 @@
+WARNING: xref-errors.pdf (xref table, file position 585): accepting invalid xref table entry
+WARNING: xref-errors.pdf (xref table, file position 606): accepting invalid xref table entry
+WARNING: xref-errors.pdf (xref table, file position 627): accepting invalid xref table entry
+WARNING: xref-errors.pdf (xref table, file position 648): accepting invalid xref table entry
+WARNING: xref-errors.pdf (xref table, file position 667): accepting invalid xref table entry
+checking xref-errors.pdf
+PDF Version: 1.3
+File is not encrypted
+File is not linearized
+1/0: uncompressed; offset = 9
+2/0: uncompressed; offset = 63
+3/0: uncompressed; offset = 135
+4/0: uncompressed; offset = 307
+5/0: uncompressed; offset = 403
+6/0: uncompressed; offset = 438
diff --git a/qpdf/qtest/qpdf/xref-errors.pdf b/qpdf/qtest/qpdf/xref-errors.pdf
new file mode 100644
index 00000000..1778ab92
--- /dev/null
+++ b/qpdf/qtest/qpdf/xref-errors.pdf
@@ -0,0 +1,79 @@
+%PDF-1.3
+1 0 obj
+<<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+
+2 0 obj
+<<
+ /Type /Pages
+ /Kids [
+ 3 0 R
+ ]
+ /Count 1
+>>
+endobj
+
+3 0 obj
+<<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 612 792]
+ /Contents 4 0 R
+ /Resources <<
+ /ProcSet 5 0 R
+ /Font <<
+ /F1 6 0 R
+ >>
+ >>
+>>
+endobj
+
+4 0 obj
+<<
+ /Length 44
+>>
+stream
+BT
+ /F1 24 Tf
+ 72 720 Td
+ (Potato) Tj
+ET
+endstream
+endobj
+
+5 0 obj
+[
+ /PDF
+ /Text
+]
+endobj
+
+6 0 obj
+<<
+ /Type /Font
+ /Subtype /Type1
+ /Name /F1
+ /BaseFont /Helvetica
+ /Encoding /WinAnsiEncoding
+>>
+endobj
+
+xref
+0 7
+0000000000 65535 f
+ 0000000009 00000 n
+0000000063 00000 n
+0000000135 00000 n
+000000307 00000 n
+0000000403 0000 n
+0000000438 00000 n
+trailer <<
+ /Size 7
+ /Root 1 0 R
+>>
+startxref
+556
+%%EOF