Commit 9e00be7ffa0c185a227e71879e37f7c6cee0485b

Authored by Jay Berkenbilt
1 parent 039eb4a2

Remove warning that gives false positives in some normal cases

libqpdf/QPDFPageObjectHelper.cc
... ... @@ -785,10 +785,12 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
785 785  
786 786 if ((! local_unresolved.empty()) && resources.isDictionary())
787 787 {
  788 + // Don't issue a warning for this case. There are some cases
  789 + // of names that aren't XObject references, for example,
  790 + // /Artifact in tagged PDF. Until we are certain that we know
  791 + // the meaning of every name in a content stream, we don't
  792 + // want to give warnings because they will be false positives.
788 793 QTC::TC("qpdf", "QPDFPageObjectHelper unresolved names");
789   - ph.oh.warnIfPossible(
790   - "Unresolved names found while scanning content stream; "
791   - "not attempting to remove unreferenced objects from this object");
792 794 return false;
793 795 }
794 796  
... ...
qpdf/qtest/qpdf.test
... ... @@ -2018,7 +2018,7 @@ my @sp_cases = (
2018 2018 [1, 'broken data', '--pages broken-lzw.pdf --', 'split-out.pdf',
2019 2019 {$td->FILE => "broken-lzw.out", $td->EXIT_STATUS => 3}],
2020 2020 );
2021   -$n_tests += 43;
  2021 +$n_tests += 42;
2022 2022 $n_compare_pdfs += 2;
2023 2023 for (@sp_cases)
2024 2024 {
... ... @@ -2178,38 +2178,27 @@ foreach my $i (qw(1 2))
2178 2178 {$td->FILE => "shared-form-xobject-split-$i.pdf"});
2179 2179 }
2180 2180  
2181   -my @fo_resources = (['form-xobjects-no-resources', 0],
2182   - ['form-xobjects-some-resources1', 3],
2183   - ['form-xobjects-some-resources2', 3]);
  2181 +my @fo_resources = (['form-xobjects-no-resources', 1],
  2182 + ['form-xobjects-some-resources1', 0],
  2183 + ['form-xobjects-some-resources2', 0]);
2184 2184 foreach my $d (@fo_resources)
2185 2185 {
2186   - my ($f, $status) = @$d;
2187   - my $expout = ($status == 0 ?
2188   - {$td->STRING => ""} :
2189   - {$td->FILE => "$f.out"});
2190   - $expout->{$td->EXIT_STATUS} = $status;
  2186 + my ($f, $compare) = @$d;
2191 2187 $td->runtest("split $f",
2192 2188 {$td->COMMAND =>
2193 2189 "qpdf --empty --static-id --pages $f.pdf 1 --" .
2194 2190 " --remove-unreferenced-resources=yes a.pdf"},
2195   - $expout, $td->NORMALIZE_NEWLINES);
  2191 + {$td->STRING => "", $td->EXIT_STATUS => 0},
  2192 + $td->NORMALIZE_NEWLINES);
2196 2193 $td->runtest("check output ($f)",
2197 2194 {$td->FILE => "a.pdf"},
2198 2195 {$td->FILE => "$f-out.pdf"});
2199   - if ($status == 0)
  2196 + if ($compare)
2200 2197 {
2201 2198 compare_pdfs("$f.pdf", "a.pdf");
2202 2199 }
2203 2200 }
2204 2201  
2205   -$td->runtest("no warn with pages warnings",
2206   - {$td->COMMAND =>
2207   - "qpdf --no-warn --empty --static-id".
2208   - " --pages form-xobjects-some-resources1.pdf 1 --" .
2209   - " --remove-unreferenced-resources=yes a.pdf"},
2210   - {$td->STRING => "", $td->EXIT_STATUS => 3},
2211   - $td->NORMALIZE_NEWLINES);
2212   -
2213 2202 show_ntests();
2214 2203 # ----------
2215 2204 $td->notify("--- Keep Files Open ---");
... ...
qpdf/qtest/qpdf/form-xobjects-some-resources1.out deleted
1   -WARNING: form-xobjects-some-resources1.pdf, stream object 8 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
2   -qpdf: operation succeeded with warnings; resulting file may have some problems
qpdf/qtest/qpdf/form-xobjects-some-resources2.out deleted
1   -WARNING: form-xobjects-some-resources2.pdf, stream object 6 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
2   -WARNING: form-xobjects-some-resources2.pdf, stream object 8 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
3   -qpdf: operation succeeded with warnings; resulting file may have some problems