Commit 4ddac544186c4964f57c2f6162f55d84c4f983f8

Authored by m-holger
1 parent 2808192c

Allow empty name objects in qpdf JSON input parsing as permitted by the PDF spec…

…ification; update release notes accordingly.

Fixes #1628
job.sums
@@ -16,6 +16,6 @@ libqpdf/qpdf/auto_job_json_decl.hh 7dbb83ddadcea39bfd1faa4ca061e1e3c3134d693b8ae @@ -16,6 +16,6 @@ libqpdf/qpdf/auto_job_json_decl.hh 7dbb83ddadcea39bfd1faa4ca061e1e3c3134d693b8ae
16 libqpdf/qpdf/auto_job_json_init.hh e9cacbcb78ca250a962c226a935067ef9b76f5485bae7e5302eea0a1a8e2ff65 16 libqpdf/qpdf/auto_job_json_init.hh e9cacbcb78ca250a962c226a935067ef9b76f5485bae7e5302eea0a1a8e2ff65
17 libqpdf/qpdf/auto_job_schema.hh 2b974a436c5b4d03fb38258d6213f993cfa9f673834cebe754b4c7ad657481c9 17 libqpdf/qpdf/auto_job_schema.hh 2b974a436c5b4d03fb38258d6213f993cfa9f673834cebe754b4c7ad657481c9
18 manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 18 manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580
19 -manual/cli.rst 0b0f6a1d8ec523751d91999586bca1356abd8f17e207bc0139ce5d7dfd64fdb4 19 +manual/cli.rst be2b9366e953fce743c115db00eeedc7894e547a9222133395e929f535fa9836
20 manual/qpdf.1 c1d6e58e37aed1b8d434b37edd1837b7261c9933b09d64bf3915dc3f35d6cccb 20 manual/qpdf.1 c1d6e58e37aed1b8d434b37edd1837b7261c9933b09d64bf3915dc3f35d6cccb
21 manual/qpdf.1.in 436ecc85d45c4c9e2dbd1725fb7f0177fb627179469f114561adf3cb6cbb677b 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,13 +146,13 @@ is_binary_string(std::string const& v, std::string& str)
146 static bool 146 static bool
147 is_name(std::string const& v) 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 static bool 152 static bool
153 is_pdf_name(std::string const& v) 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 bool 158 bool
@@ -203,10 +203,15 @@ QPDF::test_json_validators() @@ -203,10 +203,15 @@ QPDF::test_json_validators()
203 check(is_binary_string("b:12", str)); 203 check(is_binary_string("b:12", str));
204 check(is_binary_string("b:123aBC", str)); 204 check(is_binary_string("b:123aBC", str));
205 check(!is_name("")); 205 check(!is_name(""));
206 - check(!is_name("/")); 206 + check(is_name("/"));
207 check(!is_name("xyz")); 207 check(!is_name("xyz"));
208 check(is_name("/Potato")); 208 check(is_name("/Potato"));
209 check(is_name("/Potato Salad")); 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 return passed; 216 return passed;
212 #undef check_arg 217 #undef check_arg
manual/release-notes.rst
@@ -40,6 +40,9 @@ more detail. @@ -40,6 +40,9 @@ more detail.
40 flag was only set to true if the field is not a top-level field, 40 flag was only set to true if the field is not a top-level field,
41 and remained unchanged otherwise. 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 - Library Enhancements 46 - Library Enhancements
44 47
45 - Add ``QPDFNameTreeObjectHelper`` and ``QPDFNumberTreeObjectHelper`` 48 - Add ``QPDFNameTreeObjectHelper`` and ``QPDFNumberTreeObjectHelper``