Commit 4fd8dda549db2002e4d6ef24c3eaab95749c0198

Authored by m-holger
Committed by GitHub
2 parents 2808192c 4ddac544

Merge pull request #1630 from m-holger/json_name

Allow empty name objects in qpdf JSON input parsing as permitted by t…
job.sums
... ... @@ -16,6 +16,6 @@ libqpdf/qpdf/auto_job_json_decl.hh 7dbb83ddadcea39bfd1faa4ca061e1e3c3134d693b8ae
16 16 libqpdf/qpdf/auto_job_json_init.hh e9cacbcb78ca250a962c226a935067ef9b76f5485bae7e5302eea0a1a8e2ff65
17 17 libqpdf/qpdf/auto_job_schema.hh 2b974a436c5b4d03fb38258d6213f993cfa9f673834cebe754b4c7ad657481c9
18 18 manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580
19   -manual/cli.rst 0b0f6a1d8ec523751d91999586bca1356abd8f17e207bc0139ce5d7dfd64fdb4
  19 +manual/cli.rst be2b9366e953fce743c115db00eeedc7894e547a9222133395e929f535fa9836
20 20 manual/qpdf.1 c1d6e58e37aed1b8d434b37edd1837b7261c9933b09d64bf3915dc3f35d6cccb
21 21 manual/qpdf.1.in 436ecc85d45c4c9e2dbd1725fb7f0177fb627179469f114561adf3cb6cbb677b
... ...
libqpdf/QPDF_json.cc
... ... @@ -146,13 +146,13 @@ is_binary_string(std::string const& v, std::string& str)
146 146 static bool
147 147 is_name(std::string const& v)
148 148 {
149   - return ((v.length() > 1) && (v.at(0) == '/'));
  149 + return v.starts_with('/');
150 150 }
151 151  
152 152 static bool
153 153 is_pdf_name(std::string const& v)
154 154 {
155   - return ((v.length() > 3) && (v.substr(0, 3) == "n:/"));
  155 + return v.starts_with("n:/");
156 156 }
157 157  
158 158 bool
... ... @@ -203,10 +203,15 @@ QPDF::test_json_validators()
203 203 check(is_binary_string("b:12", str));
204 204 check(is_binary_string("b:123aBC", str));
205 205 check(!is_name(""));
206   - check(!is_name("/"));
  206 + check(is_name("/"));
207 207 check(!is_name("xyz"));
208 208 check(is_name("/Potato"));
209 209 check(is_name("/Potato Salad"));
  210 + check(!is_pdf_name("n:"));
  211 + check(is_pdf_name("n:/"));
  212 + check(!is_pdf_name("n:xyz"));
  213 + check(is_pdf_name("n:/Potato"));
  214 + check(is_pdf_name("n:/Potato Salad"));
210 215  
211 216 return passed;
212 217 #undef check_arg
... ...
manual/release-notes.rst
... ... @@ -40,6 +40,9 @@ more detail.
40 40 flag was only set to true if the field is not a top-level field,
41 41 and remained unchanged otherwise.
42 42  
  43 + - When parsing qpdf JSON input files allow empty name objects. These are
  44 + allowed by the PDF specification but were previously rejected.
  45 +
43 46 - Library Enhancements
44 47  
45 48 - Add ``QPDFNameTreeObjectHelper`` and ``QPDFNumberTreeObjectHelper``
... ...