Commit 7242adcacabdeae2b7aa7af87d623bca94a6cf69

Authored by m-holger
Committed by GitHub
2 parents ad3bac2c c46cfae7

Merge pull request #1447 from m-holger/i1433

Fix QPDFFormFieldObjectHelper::getChoices (fixes #1433)
include/qpdf/QPDFFormFieldObjectHelper.hh
@@ -147,7 +147,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper @@ -147,7 +147,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
147 // Returns true if fields if of type /Ch 147 // Returns true if fields if of type /Ch
148 QPDF_DLL 148 QPDF_DLL
149 bool isChoice(); 149 bool isChoice();
150 - // Returns choices as UTF-8 strings 150 + // Returns choices display values as UTF-8 strings
151 QPDF_DLL 151 QPDF_DLL
152 std::vector<std::string> getChoices(); 152 std::vector<std::string> getChoices();
153 153
libqpdf/QPDFFormFieldObjectHelper.cc
@@ -281,6 +281,11 @@ QPDFFormFieldObjectHelper::getChoices() @@ -281,6 +281,11 @@ QPDFFormFieldObjectHelper::getChoices()
281 for (auto const& item: getInheritableFieldValue("/Opt").as_array()) { 281 for (auto const& item: getInheritableFieldValue("/Opt").as_array()) {
282 if (item.isString()) { 282 if (item.isString()) {
283 result.emplace_back(item.getUTF8Value()); 283 result.emplace_back(item.getUTF8Value());
  284 + } else if (item.isArray() && item.getArrayNItems() == 2) {
  285 + auto display = item.getArrayItem(1);
  286 + if (display.isString()) {
  287 + result.emplace_back(display.getUTF8Value());
  288 + }
284 } 289 }
285 } 290 }
286 return result; 291 return result;
manual/release-notes.rst
@@ -16,20 +16,25 @@ more detail. @@ -16,20 +16,25 @@ more detail.
16 12.1.1: not yet released 16 12.1.1: not yet released
17 - Bug fixes 17 - Bug fixes
18 18
19 - - In QPDF::getAllPages detect shared /Kids arrays to avoid stack overflows  
20 - in (specially constructed) damaged input files. 19 + - In ``QPDF::getAllPages`` detect shared ``/Kids`` arrays to avoid stack
  20 + overflows in (specially constructed) damaged input files.
21 21
22 - - Fix severe performance issues in QPDFFormFieldObjectHelper with some 22 + - Fix severe performance issues in ``QPDFFormFieldObjectHelper`` with some
23 (specially constructed) damaged input files. 23 (specially constructed) damaged input files.
24 24
25 - - Add missing QPDFFormFieldObjectHelper::isChecked implementation. 25 + - Add missing ``QPDFFormFieldObjectHelper::isChecked`` implementation.
26 26
27 - - Fix bug in QPDFNameTreeObjectHelper / QPDFNumberTreeObjectHelper. Under  
28 - certain conditions tree insertions resulted in a /Range entry being  
29 - written to the tree root node, which is not permitted. One of the 27 + - Fix bug in ``QPDFNameTreeObjectHelper`` / ``QPDFNumberTreeObjectHelper``.
  28 + Under certain conditions tree insertions resulted in a ``/Range`` entry
  29 + being written to the tree root node, which is not permitted. One of the
30 possible consequences is that some readers would not recognize 30 possible consequences is that some readers would not recognize
31 embedded / attached files. 31 embedded / attached files.
32 32
  33 + - In ``QPDFFormFieldObjectHelper::getChoices`` return the display string
  34 + if an ``/Opt`` entry is a pair of export value and display string rather
  35 + than a single string representing both values. Previously no value was
  36 + returned if the entry was not a single string.
  37 +
33 - Build fixes 38 - Build fixes
34 39
35 - Improve experience for local development on Windows. Perl is no 40 - Improve experience for local development on Windows. Perl is no
qpdf/qtest/appearance-streams.test
@@ -16,7 +16,7 @@ my $td = new TestDriver(&#39;appearance-streams&#39;); @@ -16,7 +16,7 @@ my $td = new TestDriver(&#39;appearance-streams&#39;);
16 16
17 my $n_tests = 12; 17 my $n_tests = 12;
18 18
19 -foreach my $f ('need-appearances', 19 +foreach my $f ('need-appearances2',
20 'need-appearances-more', 20 'need-appearances-more',
21 'need-appearances-more2', 21 'need-appearances-more2',
22 'need-appearances-more3') 22 'need-appearances-more3')
qpdf/qtest/qpdf/need-appearances2.pdf 0 → 100644
No preview for this file type