From 7e679ab8b68a38aae8374ef28f999afd94bf5124 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 20 Dec 2023 13:28:42 -0500 Subject: [PATCH] Avoid depending on exact xref stream offsets For the modified test case, we care about successful recovery, not about the exact offsets. Add a filter to remove the specific numbers from show-xref. --- qpdf/qtest/qpdf/filter-xref-offsets.pl | 8 ++++++++ qpdf/qtest/qpdf/xref-with-short-size-new.out | 8 ++++---- qpdf/qtest/xref-streams.test | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 qpdf/qtest/qpdf/filter-xref-offsets.pl diff --git a/qpdf/qtest/qpdf/filter-xref-offsets.pl b/qpdf/qtest/qpdf/filter-xref-offsets.pl new file mode 100644 index 00000000..fa4e95c8 --- /dev/null +++ b/qpdf/qtest/qpdf/filter-xref-offsets.pl @@ -0,0 +1,8 @@ +use warnings; +use strict; + +while (<>) +{ + s/(uncompressed; offset =) \d+/$1 .../; + print; +} diff --git a/qpdf/qtest/qpdf/xref-with-short-size-new.out b/qpdf/qtest/qpdf/xref-with-short-size-new.out index 9396e6c6..1c0f409a 100644 --- a/qpdf/qtest/qpdf/xref-with-short-size-new.out +++ b/qpdf/qtest/qpdf/xref-with-short-size-new.out @@ -1,4 +1,4 @@ -1/0: uncompressed; offset = 15 +1/0: uncompressed; offset = ... 2/0: compressed; stream = 1, index = 0 3/0: compressed; stream = 1, index = 1 4/0: compressed; stream = 1, index = 2 @@ -8,6 +8,6 @@ 8/0: compressed; stream = 1, index = 6 9/0: compressed; stream = 1, index = 7 10/0: compressed; stream = 1, index = 8 -11/0: uncompressed; offset = 674 -12/0: uncompressed; offset = 801 -13/0: uncompressed; offset = 16194 +11/0: uncompressed; offset = ... +12/0: uncompressed; offset = ... +13/0: uncompressed; offset = ... diff --git a/qpdf/qtest/xref-streams.test b/qpdf/qtest/xref-streams.test index 8d8e8bd9..68640bdf 100644 --- a/qpdf/qtest/xref-streams.test +++ b/qpdf/qtest/xref-streams.test @@ -28,7 +28,8 @@ $td->runtest("recover xref with short size", $td->EXIT_STATUS => 3}, $td->NORMALIZE_NEWLINES); $td->runtest("show new xref stream", - {$td->COMMAND => "qpdf --show-xref a.pdf"}, + {$td->COMMAND => "qpdf --show-xref a.pdf", + $td->FILTER => "perl filter-xref-offsets.pl"}, {$td->FILE => "xref-with-short-size-new.out", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES);