Commit 752f43d4e4fc6348db63d17b1984116493cc5b2f

Authored by Jay Berkenbilt
1 parent 62d47bff

Allow empty b: binary JSON strings

libqpdf/QPDF_json.cc
@@ -128,7 +128,7 @@ is_binary_string(std::string const& v, std::string& str) @@ -128,7 +128,7 @@ is_binary_string(std::string const& v, std::string& str)
128 } 128 }
129 ++count; 129 ++count;
130 } 130 }
131 - return ((count > 0) && (count % 2 == 0)); 131 + return (count % 2 == 0);
132 } 132 }
133 return false; 133 return false;
134 } 134 }
@@ -180,10 +180,10 @@ QPDF::test_json_validators() @@ -180,10 +180,10 @@ QPDF::test_json_validators()
180 check(str == ""); 180 check(str == "");
181 check(!is_binary_string("", str)); 181 check(!is_binary_string("", str));
182 check(!is_binary_string("x:", str)); 182 check(!is_binary_string("x:", str));
183 - check(!is_binary_string("b:", str));  
184 check(!is_binary_string("b:1", str)); 183 check(!is_binary_string("b:1", str));
185 check(!is_binary_string("b:123", str)); 184 check(!is_binary_string("b:123", str));
186 check(!is_binary_string("b:gh", str)); 185 check(!is_binary_string("b:gh", str));
  186 + check(is_binary_string("b:", str));
187 check(is_binary_string("b:12", str)); 187 check(is_binary_string("b:12", str));
188 check(is_binary_string("b:123aBC", str)); 188 check(is_binary_string("b:123aBC", str));
189 check(!is_name("")); 189 check(!is_name(""));
qpdf/qtest/qpdf/manual-qpdf-json-out.json
@@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
94 "u:one", 94 "u:one",
95 "b:24a2", 95 "b:24a2",
96 "u:", 96 "u:",
  97 + "u:",
97 "u:()", 98 "u:()",
98 "u:(", 99 "u:(",
99 "u:)", 100 "u:)",
qpdf/qtest/qpdf/manual-qpdf-json-pdf.json
@@ -45,6 +45,7 @@ @@ -45,6 +45,7 @@
45 "u:one", 45 "u:one",
46 "b:24a2", 46 "b:24a2",
47 "u:", 47 "u:",
  48 + "u:",
48 "u:()", 49 "u:()",
49 "u:(", 50 "u:(",
50 "u:)", 51 "u:)",
qpdf/qtest/qpdf/manual-qpdf-json.json
@@ -117,6 +117,7 @@ @@ -117,6 +117,7 @@
117 "/strings": [ 117 "/strings": [
118 "u:one", 118 "u:one",
119 "b:24a2", 119 "b:24a2",
  120 + "b:",
120 "u:", 121 "u:",
121 "u:()", 122 "u:()",
122 "u:(", 123 "u:(",
qpdf/qtest/qpdf/manual-qpdf-json.pdf
@@ -47,6 +47,7 @@ endobj @@ -47,6 +47,7 @@ endobj
47 (one) 47 (one)
48 <24a2> 48 <24a2>
49 () 49 ()
  50 + ()
50 (\(\)) 51 (\(\))
51 (\() 52 (\()
52 (\)) 53 (\))
@@ -163,14 +164,14 @@ xref @@ -163,14 +164,14 @@ xref
163 0000000000 65535 f 164 0000000000 65535 f
164 0000000052 00000 n 165 0000000052 00000 n
165 0000000133 00000 n 166 0000000133 00000 n
166 -0000000829 00000 n  
167 -0000000928 00000 n  
168 -0000001029 00000 n  
169 -0000001251 00000 n  
170 -0000001322 00000 n  
171 -0000001421 00000 n  
172 -0000001467 00000 n  
173 -0000001612 00000 n 167 +0000000836 00000 n
  168 +0000000935 00000 n
  169 +0000001036 00000 n
  170 +0000001258 00000 n
  171 +0000001329 00000 n
  172 +0000001428 00000 n
  173 +0000001474 00000 n
  174 +0000001619 00000 n
174 trailer << 175 trailer <<
175 /QTest 2 0 R 176 /QTest 2 0 R
176 /Root 1 0 R 177 /Root 1 0 R
@@ -178,5 +179,5 @@ trailer &lt;&lt; @@ -178,5 +179,5 @@ trailer &lt;&lt;
178 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>] 179 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
179 >> 180 >>
180 startxref 181 startxref
181 -1648 182 +1655
182 %%EOF 183 %%EOF