From 752f43d4e4fc6348db63d17b1984116493cc5b2f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 21 May 2022 17:36:32 -0400 Subject: [PATCH] Allow empty b: binary JSON strings --- libqpdf/QPDF_json.cc | 4 ++-- qpdf/qtest/qpdf/manual-qpdf-json-out.json | 1 + qpdf/qtest/qpdf/manual-qpdf-json-pdf.json | 1 + qpdf/qtest/qpdf/manual-qpdf-json.json | 1 + qpdf/qtest/qpdf/manual-qpdf-json.pdf | 19 ++++++++++--------- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libqpdf/QPDF_json.cc b/libqpdf/QPDF_json.cc index c6fab8ad..c2ebac06 100644 --- a/libqpdf/QPDF_json.cc +++ b/libqpdf/QPDF_json.cc @@ -128,7 +128,7 @@ is_binary_string(std::string const& v, std::string& str) } ++count; } - return ((count > 0) && (count % 2 == 0)); + return (count % 2 == 0); } return false; } @@ -180,10 +180,10 @@ QPDF::test_json_validators() check(str == ""); check(!is_binary_string("", str)); check(!is_binary_string("x:", str)); - check(!is_binary_string("b:", str)); check(!is_binary_string("b:1", str)); check(!is_binary_string("b:123", str)); check(!is_binary_string("b:gh", str)); + check(is_binary_string("b:", str)); check(is_binary_string("b:12", str)); check(is_binary_string("b:123aBC", str)); check(!is_name("")); diff --git a/qpdf/qtest/qpdf/manual-qpdf-json-out.json b/qpdf/qtest/qpdf/manual-qpdf-json-out.json index 877351dd..2605c192 100644 --- a/qpdf/qtest/qpdf/manual-qpdf-json-out.json +++ b/qpdf/qtest/qpdf/manual-qpdf-json-out.json @@ -94,6 +94,7 @@ "u:one", "b:24a2", "u:", + "u:", "u:()", "u:(", "u:)", diff --git a/qpdf/qtest/qpdf/manual-qpdf-json-pdf.json b/qpdf/qtest/qpdf/manual-qpdf-json-pdf.json index 6e9520d4..9a5fc759 100644 --- a/qpdf/qtest/qpdf/manual-qpdf-json-pdf.json +++ b/qpdf/qtest/qpdf/manual-qpdf-json-pdf.json @@ -45,6 +45,7 @@ "u:one", "b:24a2", "u:", + "u:", "u:()", "u:(", "u:)", diff --git a/qpdf/qtest/qpdf/manual-qpdf-json.json b/qpdf/qtest/qpdf/manual-qpdf-json.json index 4a7a3f4e..fa7eeb78 100644 --- a/qpdf/qtest/qpdf/manual-qpdf-json.json +++ b/qpdf/qtest/qpdf/manual-qpdf-json.json @@ -117,6 +117,7 @@ "/strings": [ "u:one", "b:24a2", + "b:", "u:", "u:()", "u:(", diff --git a/qpdf/qtest/qpdf/manual-qpdf-json.pdf b/qpdf/qtest/qpdf/manual-qpdf-json.pdf index 0611bae0..39dc78c3 100644 --- a/qpdf/qtest/qpdf/manual-qpdf-json.pdf +++ b/qpdf/qtest/qpdf/manual-qpdf-json.pdf @@ -47,6 +47,7 @@ endobj (one) <24a2> () + () (\(\)) (\() (\)) @@ -163,14 +164,14 @@ xref 0000000000 65535 f 0000000052 00000 n 0000000133 00000 n -0000000829 00000 n -0000000928 00000 n -0000001029 00000 n -0000001251 00000 n -0000001322 00000 n -0000001421 00000 n -0000001467 00000 n -0000001612 00000 n +0000000836 00000 n +0000000935 00000 n +0000001036 00000 n +0000001258 00000 n +0000001329 00000 n +0000001428 00000 n +0000001474 00000 n +0000001619 00000 n trailer << /QTest 2 0 R /Root 1 0 R @@ -178,5 +179,5 @@ trailer << /ID [<31415926535897932384626433832795><31415926535897932384626433832795>] >> startxref -1648 +1655 %%EOF